Yak Posting Veteran
Posted - 05/20/2013 : 07:45:33
| I am trying to send mail to select users with following script.
declare @batch nvarchar(255)
declare @body nvarchar(255)
select @batch = min(Batch) from type
while @batch is not null
@profile_name = 'SQL Mail',
@body = @body,
@recipients = 'email@example.com',
@subject = 'E-mail to customers' ;
select @batch = min(Batch) from [type] where Batch > @batch
It works fine but sends mail with one col only.
If I change the select statement as below,
SET @BODY = SELECT *
WHERE (Batch =
I am getting error "Incorrect syntax near the keyword 'SELECT'."
I need to send the order details of customers on their mails from SQL.