I have the following SP.
this SP was built on a pre existing SP that showed activity based on the value of "added" or "deleted," which was simply done by these two lines:
Table definitions are as follows:
StartDate Int
StartTime Int
Firstlisting nvarchar
duration decimal
adddate int
addtime int
and what I'm noticing is that when I run my SP that it's returning values for both the added and deleted. I need to just show the ones that have been added, but not deleted. What would be the best way to do that with the SP that I currently have?
Thank you
Code:
SELECT moncallAdd.FirstListing, DATEADD(MINUTE, mOnCallAdd.StartOnCallTime, DATEADD(DAY, mOnCallAdd.StartOnCallDate, '12/31/1899')) AS OnCallStart, DATEADD(MINUTE, mOnCallAdd.duration, DATEADD(MINUTE, mOnCallAdd.StartOnCallTime, DATEADD(DAY, mOnCallAdd.StartOnCallDate, '12/31/1899'))) AS OnCallEnd FROM mdr.dbo.mOnCallAdd WHERE DATEADD(MINUTE, mOnCallAdd.StartOnCallTime, DATEADD(DAY, mOnCallAdd.StartOnCallDate, '12/31/1899')) BETWEEN Convert(VARCHAR(10), GetDate(), 101) AND GetDate() and mOnCallAdd.SchedName = @schedname UNION SELECT moncallDelete.FirstListing, DATEADD(MINUTE, mOnCallDelete.StartOnCallTime, DATEADD(DAY, mOnCallDelete.StartOnCallDate, '12/31/1899')) AS OnCallStart, DATEADD(MINUTE, mOnCallDelete.duration, DATEADD(MINUTE, mOnCallDelete.StartOnCallTime, DATEADD(DAY, mOnCallDelete.StartOnCallDate, '12/31/1899'))) AS OnCallEnd FROM mdr.dbo.mOnCallDelete WHERE DATEADD(MINUTE, mOnCallDelete.StartOnCallTime, DATEADD(DAY, mOnCallDelete.StartOnCallDate, '12/31/1899')) BETWEEN Convert(VARCHAR(10), GetDate(), 101) AND GetDate() and mOnCallDelete.SchedName = @schedname
Code:
'Added' AS Activity, 'Deleted' AS Activity,
StartDate Int
StartTime Int
Firstlisting nvarchar
duration decimal
adddate int
addtime int
and what I'm noticing is that when I run my SP that it's returning values for both the added and deleted. I need to just show the ones that have been added, but not deleted. What would be the best way to do that with the SP that I currently have?
Thank you
Comment