September 19, 2013 at 8:48 am
This is baffling me!
I have a proc that will call another proc to clear a record (if one exists) before adding a new one. Both procs work fine and the table ends up correct. However, I've noticed that the proc that clears the record logs that it executed at exactly the sime timeas the new record. This means that I can't see the correct order in my log table. Obviously, as the clearing proc runs BEFORE the proc that adds the new record, it should write it's log record first. The clearing proc runs at least three statements before the second one.
No problem I thought, I'll just drop a WAITFOR DELAY '00:00:00.001' after the clearing proc so that they are at least a millisecond apart and that will fix it.
Trouble is, it doesn't. The still come in at exactly the same time. If I make the delay a second, it works, but that's crap.
I tried:
select GETDATE()
waitfor delay '00:00:00.001'
select GETDATE()
And I seem to get some spurious results for anything less than 10 miliseconds.
Any ideas? Have I found a bug? Do I win a prize?
September 19, 2013 at 9:23 am
Not exactly a bug, it's just the accuracy for datetime data type.
You can read about it here.
http://technet.microsoft.com/en-us/library/ms187819%28v=sql.105%29.aspx
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply