Home > BI, Code, Misc, Tips > Obscure Timestamp DataType in SQL

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

 

VN:F [1.5.8_856]

Rating: 0.0/5 (0 votes cast)
VN:F [1.5.8_856]
Rating: 0 (from 0 votes)
Categories: BI, Code, Misc, Tips Tags:
  1. No comments yet.
  1. No trackbacks yet.