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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 error in sp_send_maildb

Author  Topic 

sqlpal2007
Posting Yak Master

200 Posts

Posted - 2008-10-22 : 09:16:43
Hello All,

I get an error when I use sp_send_maildb to execute sql query and attach results as a file.

If I use databasename..ReplResults still I get the error.

I replaced the query to select records from some other database it works fine.

Following is my command.


EXEC msdb.dbo.sp_send_dbmail @profile_name = 'Trackwise'
, @recipients = N'neweamil@company.com'
, @Query = 'SELECT * FROM ReplResults'
, @Subject = N'DATA validation'
, @attach_query_result_as_file = 1
, @query_result_width = 2000


Error:
Msg 22050, Level 16, State 1, Line 0
Error formatting query, probably invalid parameters
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 478
Query execution failed: ?Msg 208, Level 16, State 1, Server US-PROD-DW03, Line 1
Invalid object name 'ReplResults'.

Please let me know if I am doing something wrong.

Thanks,
-P

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-10-22 : 18:00:53
quote:
If I use databasename..ReplResults still I get the error.

Try
databasename.schema.ReplResults
where schema maybe DBO

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -