sql - TSQL Not Equal <> behaving differently -
i have 2 tables in sql server 2008 r2
table1 - column datecreated datetime null table2 - column datecreated datetime null when see profiler select * table1 datecreated <> '2011-06-10 00:00:00.000'
i have 3 records date
2011-06-10 00:00:00.000 2011-06-10 00:00:00.000 2011-06-10 09:45:00.000
none of records returned
on table2
select * table2 datecreated <> '2011-06-10 00:00:00.000'
i have 3 records date
2011-06-10 18:02:05.000 2011-06-10 18:05:08.000 2011-06-10 18:07:09.000
all 3 records returned. weird. why in 1st case not records when should 1 record back???
in sql, '2011-06-10 00:00:00.000' not date. string gets converted date. in database '2011-06-10 00:00:00.000' might '2011-06-10 00:00:00.00001'. maybe try using datediff(mcs,datecreated,'2011-06-10 00:00:00.000') see actual difference is.
Comments
Post a Comment