I am trying to send an email with query results in the text message. The query I am running is rather large but it seems to be having a problem with the values. I am able to run the proc with a simple select * from table statement but when I insert a value I get an incorrect syntax error. I can run the query standalone without issue. For example, when I run the following.
@profile_name = 'test',
@recipients = 'email@example.com',
@QUERY = 'SELECT * FROM tc..releasetypes where releasetype = 'u'',
@subject = 'test release type',
@body = 'Please check releasetype'
I get the following error message:
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'u'.
Can anyone assist? The query I am actually trying to run consists of query existing table for specific values and copying those values in a table variable to store values, update values in table variable, return updated values. When I paste the entire query I run into the incorrect syntax problem for value 'u'.