declare @dealID int
Set @dealID = (
Select top 1 dealID
from CRMPROD_01.dbo.P_Events_Table
LEFT OUTER JOIN tblEmails
ON CRMPROD_01.dbo.P_Events_Table.dealID = tblEmails.dealID
where eventtypeid = @eventTypeID and
((convert(char(11),EventData,100)) = '' + convert(char(11),@twoDays,100) + ''
or
(convert(char(11),EventData,100)) = '' + convert(char(11),@sevenDays,100) + '')
and tblEmails.dealID IS NULL)
|