Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

timestamp ???

1 view
Skip to first unread message

Dave

unread,
Aug 17, 2002, 5:51:40 PM8/17/02
to
I wanted to put a timestamp for each row written in my table.
I selected the timestamp from the list.
After rows were written, I come to find out the timestamp datatype was
binary.
How do I view this timestamp? how can I use it vs. a regular date datatype?

Dave,
Novice...


Erland Sommarskog

unread,
Aug 17, 2002, 6:07:31 PM8/17/02
to

To view the timestamp datatype, you look at the binary, because it is
all there is.

To wit, the timestamp datatype has nothing to do with date and time. It
is a binary value. If you update a row which has a timestamp column,
the timestamp column is automatically updated to a value which is
higher than ny previously used timestamp value in that database (or
even in the server). The main purpose for timestamp columns is
optimistic locking. You retrieve a row, and when you later update,
you compare the timestamp value with the current, and if they are
not the same, someone else has updated the row since you read it.

If you were looking for date and time, you should probably use the
datetime datatype instead.

--
Erland Sommarskog, SQL Server MVP
som...@algonet.se
Books Online (updated!) for SQL 2000 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

John Gilson

unread,
Aug 17, 2002, 6:08:37 PM8/17/02
to
In SQL Server, the TIMESTAMP data type is an 8-byte
database-wide unique identifier. I believe you mean you
have a column that should contain the current date and
time, right? You should make the data type of the column
be SMALLDATETIME or DATETIME. A DATETIME
is 8 bytes and can represent time to the millisecond. A
SMALLDATETIME is 4 bytes and can only represent time
to the minute. You can get the current date and time by
using CURRENT_TIMESTAMP, e.g.,

INSERT INTO t (current_date_time)
VALUES (CURRENT_TIMESTAMP)

Hope this helps.

jag

"Dave" <da...@dmcomm.com> wrote in message
news:Yyz79.29$r%2.109...@news.incc.net...

0 new messages