Mail Fails with SQLCMD Error

  • ramya.sqlservr

    Ten Centuries

    Points: 1068

    Comments posted to this topic are about the item Mail Fails with SQLCMD Error

  • farhana.samad

    SSC Journeyman

    Points: 77

    The Database Mail Profile that is used for the SQL server agent need to be a member of DatabaseMailUserRole in the msdb database.

  • ramya.sqlservr

    Ten Centuries

    Points: 1068

    You are right. I might have missed this point in the article - the problem here is the job worked fine when run on other databases (master,msdb etc.,) but failed only when run on user database. That's the reason it took a bit of time to narrow down the issue.

  • TheComedian


    Points: 2928

    If your service account didn't have the permissions to access your database, wouldn't other jobs be failing as well? Or is this the only time you access this specific DB?

  • ramya.sqlservr

    Ten Centuries

    Points: 1068

    I was setting up a new server and this was the only job accessing the user database at that point of time. When I was making sure all the setup was done properly, I encountered this issue.



  • Don Shoemaker

    SSC Enthusiast

    Points: 100

    I am having a new issue that is similar. However, mine appears to be unrelated to SQLAgent. My query fails when executing in SSMS. This is on a two instance install of SQL 2014, with the query working fine on Instance 1 but failing on Instance 2 . I have confirmed this on a separate dual instance installation of SQL 2014. I get "Failed to initialize sqlcmd library with error number -2147024809".


  • ramya.sqlservr

    Ten Centuries

    Points: 1068

    Are both the servers running on same service account? Could you please paste the query that is giving this error?


  • Raghavender Chavva

    SSCrazy Eights

    Points: 8669

    Thanks Buddy. Profiler suggestion helped me a lot. 🙂

    Thank You.

    Raghavender Chavva

  • Dana Medley


    Points: 6764

    Thanks for this. I know this is an older article, but it just saved my bacon.

    Everything is awesome!


    Hall of Fame

    Points: 3004

    The MSSQL certification exams spend a huge amount of time explaining NUMA nodes, but they don't mention THIS!  Thank you for pointing this out.

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

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