-- Example of mutual conversion between timestamp type and bigint type:
Set nocount on
-- Declare three timestamps
Declare @ timeflag1
Bigint
Declare @ timeflag2 bigint
Declare @ timeflag3
Bigint
-- Create a table. Field names are not required for the timestamp type.
Create Table Test (timestamp,
INT)
-- Insert 1 record timestamp. @ dbts indicates the database timestamp.
Insert into test select null, 1
Set
@ Timeflag1 = cast (@ dbts as bigint)
-- Insert 2 record Timestamp
Insert into test select
Null, 2
Set @ timeflag2 = cast (@ dbts as bigint)
-- Update 3 Record Timestamp
Update
Test Set A = 3 where a = 2
Set @ timeflag3 = cast (@ dbts
Bigint)
-- Record with timestamp 1
Select * from test where timestamp = cast (@ timeflag1
Varbinary (8 ))
-- The record with timestamp 2 does not exist anymore
Select * from test where
Timestamp = cast (@ timeflag2 as varbinary (8 ))
-- Record with timestamp 3
Select * from test
Where timestamp = cast (@ timeflag3 as varbinary (8 ))