There are
times when you want a key in your table to uniquely identify a specific row of
data. One data type in SQL Server for this is the UNIQUEIDENTIFIER. You use the
NEWID function to get a new value of this type. The keys generated are not
sequential. This data type takes up 16 bytes of space. If you do want the keys
to be in sequence, you can instead call the NEWSEQUENCEIQLID function.
SQL Server
supports the CURRENT_TIMESTAMP function. This is a SQL standard that returns
the current date and time. The data type returned is DATETIME. SQL Server also
has a proprietary function GET_DATE that does the same thing as
CURRENT_TIMESTAMP.
There is
also a SYSDATETIME function in SQL Server which will return a value of type
DATETIME2. If you are only interested in a part of this value, such as only the
date or only the time, you can use the CAST function on the result of the
function to get what you want. If you want some very specific piece of the
DATETIME, you can use the DATEPART function to extract, say, the ar.
Going the other way around, if you want to
construct a DATETIME, you can use the DATEFROMPARTS function.