The timestamp data type is managed by SQL Server. I have never seen it used everywhere except as a table column type. As such, a column of type timestamp will give you the strict serial number of the last insert / update in the row with respect to all other updates in the database. To see the last serial number of the entire database, you can get the value @@ DBTS or rowversion ().
Per http://msdn.microsoft.com/en-us/library/ms182776(SQL.90).aspx
timestamp (Transact-SQL)
is a data type that provides automatically generated unique binary numbers in a database. A timestamp is commonly used as a mechanism for stamping table rows. Storage size is 8 bytes. The timestamp data type is just an increasing number and does not save the date or time. To write a date or time, use the datetime data type.
Therefore, the volatility value of the timestamp column cannot be set and can be changed with any modification to the row. However, you can freeze the timestamp value for the varbinary (8) value.
For example, let's say you have a source table and a target table.
CREATE TABLE tblSource (
Id int not null
colData int not null
colTimestamp timestamp null)
CREATE TABLE tblTarget (
Id int not null
colData int not null
colTimestampVarBinary varbinary (8) null)
Then, during the extraction process, you can capture everything that has been updated since the last launch of the extraction process.
DECLARE @maxFrozenTargetTimestamp varchar(8)
SELECT @maxFrozenTargetTimestamp = max(colStamp) FROM tblTarget
INSERT tblTarget(Id, colData, colTimestampVarBinary)
SELECT
Id
,colData
, colTimestampVarBinary = convert(varbinary(8) colTimestamp)
FROM
tblSource
WHERE
tblSource.colTimestamp > @maxFrozenTargetTimestamp
If you were having problems, my first guess would be that the problem of your problem is in converting varchar to varbinary (8), and not to label type.
For more information (maybe too much), see the commentary (fourth shot). I left a blog post http://vadivel.blogspot.com/2004/10/about-timestamp-datatype-of-sql-server.html?showComment=1213612020000
6eorge jetson
source share