Tuesday, September 13, 2011

Beware of Timestamp in Where Clause

I have had to delete records for few dates., I tried the below query and deleted

Select * from [Some Table] where UPDATED_ON_DT = '01-Jan-2011'

but it has deleted rows only for '01-Jan-2011 00 00 000' and left other records
so, the below query solved my issue
Select * from [Some Table] where convert(Date,UPDATED_ON_DT) = '01-Jan-2011'

No comments:

Post a Comment