Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
EXEC msdb.dbo.sp_send_dbmail @profile_name = 'PTC', @recipients = 'email@email.com', @body = 'Invoices have started posting.', @subject = 'Invoices have started posting' ;
I have a table that has a field called emailflag. Table is called Email. If emailflag = 'N' then I want the above to be executed. If the flag is 'Y' I do not want the code above to be executed.
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2009-05-22 : 10:39:32
[code]declare @emailflag char(1)select @emailflag = emailflag from emailif @emailflag = 'N'beginEXEC msdb.dbo.sp_send_dbmail @profile_name = 'PTC', @recipients = 'email@email.com', @body = 'Invoices have started posting.', @subject = 'Invoices have started posting'end[/code]KH[spoiler]Time is always against us[/spoiler]