how can i run Stored Procedures the send email
but ony in condition
if the table is not empty
this is my select
---------------
SELECT * FROM [mira].[dbo].[UserBirthDay] WHERE (BirthdayToday = 1)
---------------------------------------
this is my Stored Procedures
and i wont thet if the table is empty
thet the email will not send !!
------------------
DECLARE @recipient VARCHAR(1000)
DECLARE @pstrNames VARCHAR(8000)
SET @pstrNames = ''
-- Append all results into a variable
SELECT @pstrNames = @pstrNames + ISNULL(email, '') + ';'
FROM dbo.em
-- Remove the comma at the end
IF ( RIGHT(@pstrNames, 1) = ',' )
SET @pstrNames = LEFT(@pstrNames, LEN(@pstrNames) - 1)
select @pstrNames
exec master.dbo.xp_SMTPSendMail80
@query='SELECT * FROM [mira].[dbo].[UserBirthDay] WHERE (BirthdayToday = 1) ',
@address='out.zahav.net.il',
@subject='Subject Line',
@from='midan1@zahav.net.il',
@html=1, -- Send the results as html
@Body='<html><header>header</header><body>Body Text</html></body>',
@qTableCaption='This is a Caption',
@qTableAttribute='border=2',
@recipient=@pstrNames
----------------------------
thnks ilan