Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xp_sendmail to e-mail a query in csv format

Status
Not open for further replies.

collierd

MIS
Dec 19, 2001
509
DE
Hello

I am using SQL 2000

Does anybody know if it is possible to create a query which writes to a file in csv format and then e-mails the result?

Can xp_sendmail do this?

Basically I want to send the results of a query via e-mail every night which can be viewed on their PC in Excel

If this is not possible using this method should I be using a different one?

Thanks

Damian.
 
Sample from SQL Books online with the addition of the separator key.

EXEC xp_sendmail @recipients = 'robertk@someplace.com',
@query = 'SELECT * FROM INFORMATION_SCHEMA.TABLES',
@subject = 'SQL Server Report',
@message = 'The contents of INFORMATION_SCHEMA.TABLES:',
@attach_results = 'TRUE', @width = 250, @separator = ','


You will probably be better of posting SQL server specific question in the sql server forum.

The query parameter can also call a stored procedure if that works better for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top