Hi guys,
I am trying to create a SQL mail job to send me the results of a query what I created and saved as a stored procedure and named it dbo.stpGetBankrek
If I try to create a job and sending me the results in a body in the email the job gives me the error code: failed to initialze sqlcmd library wit error 2147467259. [SQLState 42000] (error 22050) step failed.
the command I made was:
DECLARE @return_value int
EXEC @return_value = [dbo].[stpGetBankrek]
SELECT 'Return Value' = @return_value
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'sql mail profile'
, @recipients = 'XXXXXXXX'
, @subject = 'queryresultset'
, @body_format = 'TEXT'
, @query = '@query'
, @execute_query_database = 'dbo.stpgetbankrek'
, @attach_query_result_as_file = 0
, @query_result_header = 1
, @query_result_width = 80
, @query_result_separator = ' '
,...