Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Can i use timestamp in order by
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

17 Posts

Posted - 01/10/2014 :  02:44:41  Show Profile  Reply with Quote
Dear all,(sqlserver 2005)

i want to save the largest timestamp in a variable then

i want to get the changed and inserted record from a table

like select * from t where timestamp>@timestamp

is the above is correct ( basically i wanted timestamp to use in my stored proc which can

get me differential from database)

2) I could not under stand , how duplicate are getting created ,please tel me how following is possible.(

Duplicate timestamp values can be generated by using the SELECT INTO statement in which a timestamp column is in the SELECT list. We do not recommend using timestamp in this manner.

yours sincerely

Edited by - rajemessage on 01/10/2014 02:45:55

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 01/10/2014 :  07:39:46  Show Profile  Reply with Quote
timestamp is a internal generated binary value based on system datetime values. the definition says below

This counter is the database timestamp. This tracks a relative time within a database, not an actual time that can be associated with a clock

this would cause chances of it getting duplicate values. Please keep in mind that timestamp column in SQL Server is not same as that in many other RDBMS systems. it has no relation directly to date or time. Its a rowversioning mechanism thats why its recommended to use rowversion counter part for new developments.

If your intention is to capture audit trail information you must use datetime or datetime2 type field (depending on upto what precision level you want). This will make sure your comparison using field would work as intended.

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000