use Insurance
go
select Customer.CustomerID ,Customer.FirstName ,Customer.LastName ,Customer.Birthda,Customer.Email
from Customer
where
DAY([Birthday]) = DAY(GETDATE())
AND MONTH([Birthday]) = MONTH(GETDATE())
declare @Receipientlist nvarchar(max)
set @Receipientlist =
STUFF((SELECT N';' + Email
FROM dbo.Customer
WHERE DAY([Birthday]) = DAY(GETDATE())
AND MONTH([Birthday]) = MONTH(GETDATE())
FOR XML PATH(N''),TYPE).value('.','nvarchar(max)'), 1, 1,N'');
EXEC msdb.dbo.sp_send_dbmail @profile_name='test',
@recipients=@Receipientlist,
@subject='Insurance',
@body='Happy Birthday.
Today is your Birthday.'
If i execute the query manually works fine, if create a job for it or execute step by step comes error:
SELECT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations. [SQLSTATE 42000] (Error 1934). The step failed.,00:00:00,16,1934,,,,0