sp_send_email doesnt work when you insert @query

  • Hi all

    I have an issue when i try this it gives me an error i tried different things and it doesnt seem to work it works without the query i can get emails coming through fine. can you please help?

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'SQLServer',

    @recipients = 'bob@hotmail.com',

    @subject = 'Memory Values',

    @query = 'SELECT * FROM Memory',

    @attach_query_result_as_file = 0;

    Msg 22050, Level 16, State 1, Line 39

    Failed to initialize sqlcmd library with error number -2147467259.

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • "Failed to initialize sqlcmd library with error number" is usually an error in your SQL Query, either syntax or permissions.

    Is it running in the correct database context?

  • you are right i have changed the account of sql to a service account and it works it was permission issue thank you

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

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