October 12, 2012 at 4:02 am
I am using code below, attempting to save query results to a file to be emailed using the Send DBMail SP (which I now have working)
But when executing this -
exec msdb.dbo.sp_send_dbmail
@profile_name = 'Default Public Profile',
@recipients = 'example@example.com',
--@copy_recipients = 'example@example.com',
@subject = 'I022 flows',
@query = 'select * from [GATEKEEPER].[dbo].[DATAFLOW_CLOB] where [RAW_CLOB]
LIKE 'AAA|S0141007%SPH%'',
@attach_query_result_as_file = 1,
@query_attachment_filename = 'test.csv'
GO
I'm getting this error -
Msg 102, Level 15, State 1, Line 9
Incorrect syntax near 'AAA'.
I can understand why as I'm effectively closing the select query with the apostrophe so it doesn't pick up the AAA onwards, I'm just wondering if anyone knows a way around this.
Thanks for any help in advance.
October 12, 2012 at 4:35 am
Add more apostrophes 🙂
exec msdb.dbo.sp_send_dbmail
@profile_name = 'Default Public Profile',
@recipients = 'example@example.com',
--@copy_recipients = 'example@example.com',
@subject = 'I022 flows',
@query = 'select * from [GATEKEEPER].[dbo].[DATAFLOW_CLOB] where [RAW_CLOB]
LIKE ''AAA|S0141007%SPH%''',
@attach_query_result_as_file = 1,
@query_attachment_filename = 'test.csv'
GO
October 12, 2012 at 4:54 am
Thanks 🙂 that worked.
October 12, 2012 at 7:40 am
No problem 🙂
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply