Not really a sql programmer. It looks to me that its looking for anything where exch_date is today and deleting it. Is that correct?
DELETE FROM dbo.Table where
DATEADD(dd, DATEDIFF(dd,0,exch_Date),0) = DATEADD(dd, DATEDIFF(dd,0,GETDATE()),0)
One way to validate this is to input it into a select statement. This will help you identify all the rows that will be affected.
Select * from db.table
where DATEADD(dd, DATEDIFF(dd,0,exch_Date), 0)
= DATEADD(dd, DATEDIFF(dd,0,GETDATE()), 0)
It appears to be doing a whole day (as in no time component) comparison between exch_Date and the current date.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With