Understanding TIMESTAMP (ROWVERSION) in SQL Server
page 2 of 7
by Abhishek Kumar Singh
Feedback
Average Rating: 
Views (Total / Last 10 Days): 15088/ 423

Using TIMESTAMP in CREATE TABLE command

Wikipedia.org defines timestamp in very clear manner, as follows:

A timestamp is a sequence of characters, denoting the date and/or time at which a certain event occurred.

To go ahead, let us create a table with the following structure:

Listing 1

CREATE TABLE MyTestTable(RowID INT IDENTITY(1,1) NOT NULL,
[TimeStampTIMESTAMP, [SmallDateTime] SMALLDATETIME,
[DateTime]  DATETIME)

OR

Listing 2

CREATE TABLE MyTestTable1(RowID INT IDENTITY(1,1) NOT NULL,
TIMESTAMP, [SmallDateTimeSMALLDATETIME,
[DateTime]  DATETIME)

Notice the second statement - If we just specify data type TIMESTAMP without a column name for it then SQL Server automatically sets its column name as "Timestamp."

Please note that a table can have only one TIMESTAMP column. We can have either of a TIMESTAMP or ROWVERSION column type in table, but not both. I have used column type TIMESTAMP in the above table CREATE command.


View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 1 and 8 and type the answer here:

User Comments

Title: timestamp problem   
Name: arpizt
Date: 10/29/2009 9:35:55 PM
Comment:
"UPDATE table SET field = current_timestamp where (field=1)"
Error msg this field cannot been update.

Thanks.
Title: arpizt@gmail.com   
Name: abhishek
Date: 10/28/2009 6:41:21 PM
Comment:
arpizt@gmail.com can you post your query here?
Title: timestamp problem   
Name: arpizt@gmail.com
Date: 10/27/2009 5:53:58 AM
Comment:
Hi,

I try to run the insert sql, but got this error ("Column or expression 'PaymentDate' cannot be updated." Why? How to overcome this problem?
Title: Abhishek Your Time Stamp Aarticle too good   
Name: Gbbs Mith
Date: 6/13/2009 5:02:18 AM
Comment:
The article is very good because it was justified clearly time and datetime data type. Hope more such article

Thanks
Title: Beginner   
Name: nagarajan
Date: 3/17/2009 9:47:06 AM
Comment:
excellent artice about TIMESTAMP.
Title: job   
Name: eak
Date: 1/8/2009 2:17:28 AM
Comment:
http://www.sqlhacks.com/index.php/Dates/Timestamp
Title: good   
Name: Jen
Date: 12/18/2008 4:57:37 AM
Comment:
good for quick walkthrough.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2009 ASPAlliance.com  |  Page Processed at 11/21/2009 12:53:22 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search