Obscure Timestamp DataType in SQL
In SQL Server, a Timestamp field helps to keep track of changes to a table in a Database.
To use it, you simply define a field without a name, and a data type of TIMESTAMP.
SQL Server automatically inserts an internal identifier into the column whenever a row is inserted or updated. To get the current value use ‘SELECT @@DBTS.
CREATE TABLE .t2
(
a int NULL,
b int NULL,
timestamp NULL
) ON [PRIMARY]
GO
COMMIT
insert into t
(a, b)
values (1, 2)
SELECT @@DBTS DBTS
|
DBTS |
|
0x00000000000007E6 |
select * from t
|
a |
b |
timestamp |
|
1 |
2 |
0x00000000000007E2 |
|
1 |
2 |
0x00000000000007E3 |
|
1 |
2 |
0x00000000000007E4 |
|
1 |
2 |
0x00000000000007E5 |
|
1 |
2 |
0x00000000000007E6 |
Recent Buzz