Select * into #temp from CRMPROD_01.dbo.P_Events_Table where EventTypeID not in (24,33) and EventData > getdate() -2
Select dealID, CONVERT(VARCHAR(10), eventdata,101) as EventDate,
CONVERT(VARCHAR(10), dbo.fn_AddBizDays(EventData, - 2),101) as TwoDayNotification,
CONVERT(VARCHAR(10), dbo.fn_AddBizDays(EventData, - 7),101) as SevenDayNotification
from #temp
Where EventTypeID = 14
And CONVERT(VARCHAR(10), eventdata,101) = CONVERT(VARCHAR(10),getdate() + 2,101)
order by EventData, dealID
|