all groups > sql server connect > september 2003 >
You're in the

sql server connect

group:

dangerous bug in sql 2000


dangerous bug in sql 2000 Pete Gajria
9/26/2003 3:07:03 PM
sql server connect: Hi,
looks like sql server 2000 (no sp) can't distinguish between
2 rows with timestamps less than 3ms apart
in other words if you query a bunch of rows with a date > expression in the
where
clause in a select statement it will actually drop rows

heres an example


select top 5 id, modified_date
from test
where modified_date is not null
order by modified_date ASC

250136 2003-04-08 11:50:40.390
572016 2003-04-08 11:51:05.357
801365 2003-04-08 11:51:07.467
800755 2003-04-08 11:51:15.763
801159 2003-04-08 11:51:16.437

now with the where clause

select top 5 id, modified_date
from test
where modified_date > '2003-04-08 11:51:05.355' <-- 2 ms less than .357
order by modified_date ASC

801365 2003-04-08 11:51:07.467
800755 2003-04-08 11:51:15.763
801159 2003-04-08 11:51:16.437
131901 2003-04-08 11:51:17.153

& it dropped the first row with 357ms which should have been included.

is there any workaround for this ?

ive never seen a database do this & im amazed it could slip pass qc.

regards,
pete

Re: dangerous bug in sql 2000 John Bell
9/27/2003 10:52:47 AM
Hi

The granularity of datetime is well documented in Books online.

John

[quoted text, click to view]

Re: dangerous bug in sql 2000 Neil Pike
9/28/2003 6:25:22 PM
Pete,

Fully documented and has ALWAYS been the case with SQL Server.

[quoted text, click to view]

Neil Pike MVP/MCSE. Protech Computing Ltd
Reply here - no email
SQL FAQ (484 entries) see
http://forumsb.compuserve.com/gvforums/UK/default.asp?SRV=MSDevApps
(faqxxx.zip in lib 7)
or www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
or www.sqlserverfaq.com
or www.mssqlserver.com/faq
Re: dangerous bug in sql 2000 Pete Gajria
9/30/2003 11:06:44 AM
Hi Neil,
Thanks for the followup
Now is there any workaround to this issue ?

Regards,
Pete


On Sun, 28 Sep 2003 18:25:22 +0100, Neil Pike <neilpike@compuserve.com>
[quoted text, click to view]



--
Re: dangerous bug in sql 2000 Kalen Delaney
9/30/2003 3:44:58 PM
Hi Pete

Workarounds are for bugs and this is not a bug. Datetime values can only
store time to a precision of 1/300 of a second.
It's like asking for a workaround for the fact that an bigint can only store
values up to 2^64.
That is the limit of the precision available.

--
HTH
----------------
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com


[quoted text, click to view]

Re: dangerous bug in sql 2000 John Bell
10/1/2003 8:06:09 AM
Hi

Your design already has an id column, if this is unique for any given time,
you will just need to bring that into play. e.g. use min(id) for a given
time.

John

[quoted text, click to view]

Re: dangerous bug in sql 2000 Neil Pike
10/1/2003 4:14:52 PM
Pete - the only "workaround" would be to hold it in a different datatype -
e.g. numeric/bigint. You're not going to be able to use the builtin datetime
functions against any non-datetime datatype though.

[quoted text, click to view]

Neil Pike MVP/MCSE. Protech Computing Ltd
Reply here - no email
SQL FAQ (484 entries) see
http://forumsb.compuserve.com/gvforums/UK/default.asp?SRV=MSDevApps
(faqxxx.zip in lib 7)
or www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
or www.sqlserverfaq.com
or www.mssqlserver.com/faq
AddThis Social Bookmark Button