Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Can i use timestamp in order by to get records which are changed , inserted after old time stamp Expand / Collapse
Author
Message
Posted Friday, January 10, 2014 12:35 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, July 28, 2014 10:33 PM
Points: 47, Visits: 143
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 it 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


Post #1529652
Posted Friday, January 10, 2014 12:42 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 12:13 PM
Points: 13,356, Visits: 10,220
The name timestamp is very badly chosen. It is a binary number, not an actual date.
Given the issues with timestamp, wouldn't it be easier to just use an IDENTITY column? This simply increments for every new record.
You can have gaps (if transactions fail for example), but as long as you don't mess with the column new values have always bigger values than the previous ones and duplicates do not occur.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1529655
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse