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.
Author |
Topic |
khana04
Starting Member
4 Posts |
Posted - 2007-01-22 : 00:24:28
|
I am using xp_sendmail to send the result of store procedure dbo.Preview_JE to e-mail as and excel attachment but I am getting an error "ODBC error 2812 (42000) Could not find stored procedure 'dbo.Preview_JE'. not sure what I am doing wrong.below is my syntaxEXEC master.dbo.xp_SendMail @recipients = 'Azeem.khan29@t-mobile.com' , @message = 'See attached file.' , @query = 'exec dbo.Preview_JE' , @attachments = 'JEPreview.xls' , @subject = 'Journal Entry' , @attach_results = 'true'Thanks for help in advance!!! |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-22 : 01:09:15
|
Most probably that stored procedure does not exist in the current database.Prefix the dbo.Preview_JE stored procedure with the right database, like thisEXEC master.dbo.xp_SendMail @recipients = 'Azeem.khan29@t-mobile.com', @message = 'See attached file.', @query = 'exec xyz.dbo.Preview_JE', @attachments = 'JEPreview.xls', @subject = 'Journal Entry', @attach_results = 'true'Or try this approachCREATE TABLE ##texttab (c1, c2, c3 ...)INSERT ##texttab exec xyz.dbo.Preview_JEDECLARE @cmd varchar(56)SET @cmd = 'SELECT * FROM ##texttab'EXEC master.dbo.xp_SendMail @recipients = 'Azeem.khan29@t-mobile.com', @message = 'See attached file.', @query = @cmd, @attachments = 'JEPreview.xls', @subject = 'Journal Entry', @attach_results = 'true', @no_header= 'TRUE'DROP TABLE ##texttabPeter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|