SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

rajemessage
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.(http://technet.microsoft.com/en-us/library/ms182776%28v=sql.90%29.aspx)

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

visakh16
Very Important crosS Applying yaK Herder

India
52309 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.
http://technet.microsoft.com/en-us/library/ms182776.aspx

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
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000