Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Running SQL queries & attach to email

Author  Topic 

ahmedpower
Starting Member

6 Posts

Posted - 2012-12-11 : 06:51:33
Is there any Application to Running SQL queries & attach to email with scheduler .

Please support. Thanks

Ahmed Soliman

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-12-11 : 07:11:37
Have a look at dbmail.
http://msdn.microsoft.com/en-us/library/ms175887(v=sql.105).aspx

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2012-12-11 : 07:17:26
SQL Server comes with Database Mail . Configure Database mail and then use the msdb.dbo.sp_send_dbmail stored procedure ,with SQL Server Agent . Here is an example of the built in stored procedure. Using the @attach_query_result_as_file will attach the query results

EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Main',
@body = 'some body text',
@subject = 'some subject text' ,
@recipients = 'user1@sqlserver-dba.com',
@execute_query_database = 'MY_DB',
@attach_query_result_as_file = 1,
@query = 'EXEC mySp'
go

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -