sql server - Formatting query of TSQL -


i have following tsql query attempting run results , attach email having issues formatting of query, can advise why not working?

declare @query_attachment_filename varchar(100) = 'reconciliation-count-ending-' + convert(varchar(10), getdate(), 112) + '.csv';  exec msdb.dbo.sp_send_dbmail @profile_name = 'support', @recipients = 'johnpaul@energy.co.uk;martin@energy.co.uk', @subject = 'reconciliation count', @query = n'set ansi_warnings off;set nocount on;select * (     select a.new_messagetypecode     new_marketmessagein     createdon between dateadd(day, –1, getdate()) , getdate() ) src pivot (count(new_messagetypecode ) new_messagetypecode in ([014r], [101], [101p], [101r], [102], [102p], [102r], [105], [105l], [106d], [106e], [110], [111], [111a], [111l], [111r], [112], [112r], [112w], [114], [115], [115r], [116], [116a], [116n], [116r],[117d],[117r], [122], [122r], [130d], [130r], [131], [137r], [261], [300], [300s], [300w], [301], [301n], [303r], [305], [306], [306w], [307], [307w], [308], [310], [310w], [311], [320], [320w], [321], [330], [331], [332], [332w], [341],[342], [352r], [591], [594], [595], [596], [597], [598], [601], [602], [700], [700w], [701], [701w])) test ;', @attach_query_result_as_file = 1, @query_attachment_filename = @query_attachment_filename, @query_result_header =0, @query_result_separator = ' ' 

the error is:

executed user: nt authority\network service. error formatting query, invalid parameters [sqlstate 42000] (error 22050). step failed


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -