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
 SQL Server Administration (2005)
 Problem in executing msdb.dbo.sp_send_dbmail

Author  Topic 

rahul170
Starting Member

3 Posts

Posted - 2009-02-18 : 07:44:50
We have an automated job scheduled at clients’s databases on Sql Server 2005. The job runs some validation scripts and sends results of the scripts via email. For one client the job is running perfectly but on another client, it is giving following error:

Msg 22050, Level 16, State 1, Line 0
Error executing extended stored procedure: Invalid Parameter

Below is the script which runs as scheduled job:

declare @mail_list varchar(100)
set @Mail_list = 'abc@xyz.com'
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Email_ProfileName',
@recipients = 'abc@xyz.org',
@copy_recipients = @Mail_list,
@query = 'EXEC TPRO.dbo.Data_Check_Notification_Procedure_SP',
@subject = 'Subject',
@body = 'Body Text',
@attach_query_result_as_file = 1,
@query_attachment_filename ='Validation_Results.txt' ;

I tried running the following script:
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'EMAIL_ProfileName',
@recipients='abc@xyz.com',
--@query = 'select getdate()',
@body = 'Hello',
@body_format = 'TEXT',
@subject = 'Subject'

If I comment @query parameter in the query above, it runs fine. But running the query with @query parameter gives the same error.

We have tried to run the job using both Windows authentication and SQL authentication

Is there any permissin related problem?

Any help on this topic will be highly appreciated


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-18 : 10:08:03
duplicate

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=120063
Go to Top of Page
   

- Advertisement -