|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Incorrect syntax near '+'!What's wrong with the following code?
EXEC xp_sendmail @recipients***@b.com', @copy_recipients***@c.com;*@d.com;*@e.com', @subject='SQL Server Report!', @message='Report generated on' + CAST(GETDATE() AS varchar(50)) + '!', @query='SELECT * FROM INFORMATION_SCHEMA.TABLES', @attach_results='TRUE', @width=250 The above, when executed, throws an error saying "Incorrect syntax near '+' pointing to the @message statement. Where am I erring? Thanks, Arpan I don't think you can use "+" in the call to a stored proc like you are
below. Try this: DECLARE @msg VARCHAR(80) SET @msg = 'Report generated on' + CAST(GETDATE() AS varchar(50)) + '!' EXEC xp_sendmail @recipients***@b.com', @copy_recipients***@c.com;*@d.com;*@e.com', @subject='SQL Server Report!', @message= @msg, @query='SELECT * FROM INFORMATION_SCHEMA.TABLES', @attach_results='TRUE', @width=250 - Steve Show quote "Arpan" <arpan***@hotmail.com> wrote in message news:1120295790.949941.306740@g49g2000cwa.googlegroups.com... > What's wrong with the following code? > > EXEC xp_sendmail > @recipients***@b.com', > @copy_recipients***@c.com;*@d.com;*@e.com', > @subject='SQL Server Report!', > @message='Report generated on' + CAST(GETDATE() AS varchar(50)) + '!', > @query='SELECT * FROM INFORMATION_SCHEMA.TABLES', > @attach_results='TRUE', > @width=250 > > The above, when executed, throws an error saying "Incorrect syntax near > '+' pointing to the @message statement. Where am I erring? > > Thanks, > > Arpan > |
|||||||||||||||||||||||