It looks like SQL Server 2008 has nanosecond precision for the time datatype
[edit]I just looked at BOL and yes nanoseconds = ns, microsecond = mcs when used in dateadd[/edit]
If you run the following
DECLARE
@t time
SELECT
@t ='0:0'
SELECT
@t AS Time1,DATEADD(ms,1,@t) AS TimeMilli,
DATEADD
(ns,10000,@t) AS TimeNano1,DATEADD(ns,100,@t) AS TimeNano2
The output is this
Time1 00
:00:00.0000000
TimeMilli 00
:00:00.0010000
TimeNano1 00
:00:00.0000100
TimeNano2 00
:00:00.0000001
Another interesting thing is that you can't use 0,'0' or ' ' to assign a value
These 3 will all fail
DECLARE
@t time
SELECT
@t =' '
DECLARE
@t time
SELECT
@t ='0'
DECLARE @t time
SELECT
@t =0
But this one will succeed
DECLARE
@t time
SELECT
@t =''
Comment Notification
If you would like to receive an email when updates are made to this post, please register here
Subscribe to this post's comments using
About Denis Gobo
I was born in Croatia in 1970, when I was one I moved to Amsterdam (and yes Ajax is THE team in Holland) and finally in 1993 I came to the US. I have lived in New York City for a bunch of years and currently live in Princeton, New Jersey with my wife and 3 kids. I work for Dow Jones as a Database architect in the indexes department, one drawback: since our data goes back all the way to May 1896 I cannot use smalldates ;-(
I have been working with SQL server since version 6.5 and compared to all the other bloggers here I am a n00b.
Some of you might know me from http://sqlservercode.blogspot.com/ or even from some of the newsgroups where I go by the name Denis the SQL Menace
If you are a Tek-Tips user then you might know me by the name SQLDenis, I am one of the guys answering SQL Questions in the SQL Programming forum.