Click here to monitor SSC
SQLServerCentral is supported by Redgate
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
Posted Friday, January 10, 2014 12:35 AM


Group: General Forum Members
Last Login: Wednesday, November 30, 2016 7:48 AM
Points: 150, Visits: 328
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.(

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



Group: General Forum Members
Last Login: Yesterday @ 1:35 AM
Points: 15,510, Visits: 13,170
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 SQLKover.

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

Add to briefcase

Permissions Expand / Collapse