Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Programming / SQL / December 2008

Tip: Looking for answers? Try searching our database.

Best way to send a result query via e-mail?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don Juan - 19 Jul 2008 09:06 GMT
Hi all

What is the best way in order to send an SQL query via e-mail?
What can I do in sql server side? or programatically? (VB or C#)

Thanks in advanced.
dj
Plamen Ratchev - 19 Jul 2008 13:17 GMT
Assuming you mean the query results, you can use the system stored procedure
sp_send_dbmail using the @query parameter. Here is example:

EXEC msdb.dbo.sp_send_dbmail
      @profile_name = 'MyProfile',
      @recipients = 'foo@test.com',
      @query = 'SELECT col1 FROM Foo' ,
      @subject = 'Query results',
      @attach_query_result_as_file = 1 ;

HTH,

Plamen Ratchev
http://www.SQLStudio.com
Don Juan - 22 Jul 2008 06:57 GMT
Thanks!

> Assuming you mean the query results, you can use the system stored
> procedure sp_send_dbmail using the @query parameter. Here is example:
[quoted text clipped - 10 lines]
> Plamen Ratchev
> http://www.SQLStudio.com
Robert Bedick - 24 Dec 2008 19:07 GMT
You might want to consider using QueryToDoc Command Line Publisher (http://www.schematodoc.com). It's a console app that lets you run a query on a recurring schedule and have the results sent to people as an e-mail attachment in a Word, HTML, Excel or CSV format.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.