How to fetch last generated timestamp of a database?
Global variable @@DBTS returns the last used timestamp value for the current database.
Its return type is varbinary.
When ever any record is inserted or updated a new timestamp gets generated and the new generated value can be fetched using @@DBTS.
Example:
Use Master
Go
Create DataBase SQLCommitted
Go
SELECT @@DBTS
Output1 : 0x0000000000000FA0
Now lets create a table ,insert a record into it and will compare the Col2 value with @@DBTS
Create Table T1( Col1 int, Col2 timestamp)
Go
Insert T1 (Col1) values (1)
Go
Select @@DBTS, Col2 from T1
Output2: 0x0000000000000FA1, 0x0000000000000FA1
In Output2 we can see both @@DBTS and Col2 returns same value.
No comments yet.
Leave a Reply
-
Archives
- March 2013 (1)
- January 2013 (3)
- December 2012 (2)
- November 2012 (1)
- August 2012 (4)
- July 2012 (2)
- June 2012 (2)
- May 2012 (1)
- April 2012 (5)
- March 2012 (1)
- February 2012 (1)
- January 2012 (5)
-
Categories
-
RSS
Entries RSS
Comments RSS

