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

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Can i use timestamp in order by

Author  Topic 

rajemessage
Starting Member

17 Posts

Posted - 2014-01-10 : 02:44:41
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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-10 : 07:39:46
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
   

- Advertisement -