locked
Error Inside SQL Server Agent Job View History RRS feed

  • Question

  • Hello,

    I have a script which basically reports some info about sql servers daily via email. The Database Mail is correctly setup. SQL2k16 enterprise edition. When I run the script inside Query window (interactive), it works fine and do I do get the email. However, when I run the script inside a SQL server agent job, I see following error in the sql server agent job history:

    Executed as user: mydomain\ADsqlserverserviceaccount. Failed to initialize sqlcmd library with error number -2147467259. [SQLSTATE 42000] (Error 22050).  The step failed. 

    Will really appreciate your help on fixing this.

    Thanks.

    Victor


    Victor

    Friday, May 24, 2019 8:17 PM

Answers

  • Make sure that the user mydomain\ADsqlserverserviceaccount is the member of the DatabaseMailUserRole.

    A Fan of SSIS, SSRS and SSAS

    • Marked as answer by vr123 Friday, May 24, 2019 11:04 PM
    Friday, May 24, 2019 8:44 PM

All replies

  • Make sure that the user mydomain\ADsqlserverserviceaccount is the member of the DatabaseMailUserRole.

    A Fan of SSIS, SSRS and SSAS

    • Marked as answer by vr123 Friday, May 24, 2019 11:04 PM
    Friday, May 24, 2019 8:44 PM
  • The AD service account was not even added to the logins. After adding and granting the permissions, the agent job ran fine. Thanks.

    Victor


    Victor

    Friday, May 24, 2019 11:05 PM