all groups > sql server programming > april 2007 >
You're in the

sql server programming

group:

how view value of Transact-SQL 'timestamp' column?


how view value of Transact-SQL 'timestamp' column? Rick Charnes
4/30/2007 4:04:03 PM
sql server programming: How can I view the actual date and time value of a Transact-SQL
'timestamp' column? I see that it's a string of binary numbers. Can
this be translated into a real data and time, or is just a way of
version-stamping table rows that really has nothing to do with an actual
Re: how view value of Transact-SQL 'timestamp' column? Aaron Bertrand [SQL Server MVP]
4/30/2007 4:11:16 PM
TIMESTAMP does NOT contain any data about date and time. You should use a
DATETIME column for this. Your latter description is exactly what it's
for... see the documentation on ROWVERSION.

--
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006





[quoted text, click to view]

Re: how view value of Transact-SQL 'timestamp' column? sloan
5/1/2007 12:00:00 AM

You can convert it to an int.

Select EmpID , convert( EmpRowVers , int ) as EmpRowVersInt from dbo.Emp

(( where EmpRowVers is a timestamp column ))

As previously stated, it has nothing to do with datetime.


As stated, please review ROWVERSION documentation.


I'd create a table, (as above).
EmpID int , EmpName varchar(32) , EmpRowVers timestamp

Throw 2 or 3 records in it.

Run this query

Select EmpID , convert( EmpRowVers , int ) as EmpRowVersInt from dbo.Emp

Run this query
Update Emp Set EmpName = 'Jones' where EmpName = 'Smith'

run
Select EmpID , convert( EmpRowVers , int ) as EmpRowVersInt from dbo.Emp

and you'll see the RowVers in action.

DO NOT ASSUME FUNCTIONALITY, READ THE Books Online (BOL).




[quoted text, click to view]

Re: how view value of Transact-SQL 'timestamp' column? Aaron Kempf
5/1/2007 12:12:20 PM
yeah I've got a dozen people over here that disagree.

they think that it's ok to name soemthing timestamp ; when it's really a
datetime field



[quoted text, click to view]

Re: how view value of Transact-SQL 'timestamp' column? Aaron Bertrand [SQL Server MVP]
5/1/2007 3:18:28 PM
[quoted text, click to view]

Well, naming a column [timestamp] is not the best decision, but unless
you're aware that Microsoft chose a poor alias for ROWVERSION, you wouldn't
know why... and it seems a logical choice (albeit Celko would bark,
"timestamp of WHAT?").

I'm talking more about the usage of the TIMESTAMP data type, and it also
seems logical that a lot of people get confused and don't realize that this
has nothing to do with time...

A

AddThis Social Bookmark Button