0

when i am executing the below query, I am getting error as:-

Msg 22050, Level 16, State 1, Line 4 Failed to initialize sqlcmd library with error number -2147467259.

This is my query:-

EXEC msdb.dbo.sp_send_dbmail  
@profile_name = 'Mail Alerts',  
@recipients = 'v-pusah@microsoft.com',  
 @subject = 'Overlapping Subscriptions',
@body = 'kaise ho',
 @query = 'select b_id from tp_sub', 

@attach_query_result_as_file = 1, @query_attachment_filename = 'result.txt', @query_result_separator=',',@query_result_width =5000000, @query_result_no_padding=1

0

the solution was to specify the database prefix in the sql query in the @query parameter. After lot of scratch on my head i realized without prefixing DB name+Schema in Exec @query it will not work.

Did not work: @query = 'SELECT fields FROM table' Works: @query = 'SELECT fields FROM database..table'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.