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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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
 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
2179 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  
 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.03 seconds. Powered By: Snitz Forums 2000