Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sp_send_dbmail

Status
Not open for further replies.
Jul 21, 2009
13
US
Hi,

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.

begin
exec msdb.dbo.sp_Send_dbmail
@profile_name = 'test',
@recipients = 'test@test.com',
@QUERY = 'SELECT * FROM tc..releasetypes where releasetype = 'u'',
@subject = 'test release type',
@body = 'Please check releasetype'
END

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'.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top