Problem in executing msdb.dbo.sp_send_dbmail

  • 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

  • Duplicate post. Please post answers here: http://qa.sqlservercentral.com/Forums/Topic659347-146-1.aspx

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply