SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Running SQL queries & attach to email
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ahmedpower
Starting Member

Qatar
6 Posts

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

Please support. Thanks

Ahmed Soliman

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 12/11/2012 :  07:11:37  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
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
Flowing Fount of Yak Knowledge

United Kingdom
2067 Posts

Posted - 12/11/2012 :  07:17:26  Show Profile  Visit jackv's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000