sp_send_dbmail is not working with @query Parameter

  • Hi,

    I have a job which have 1 step for sending mail through sp_send_dbmail .

    its working smothly with out @query in Job.when i use @query Parameter then Job failed with

    Error "Probably invalid parameter [SQLSTATE 42000][error 22050].

    Please provide solution.

  • I'll assume you tested the query outside the context of sp_send_dbmail and there's no problems with the query itself...

    One suggestion would be to make sure all objects are fully qualified with the name of the database. This is because when you execute sp_send_dbmail the query referenced by the @query parameter is run from the context of the master database.

  • Thanks for reply .

    this script working propery in query anlyser.

    but as same in job will give error as mention.

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

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