Sqlserver timestamp Data Type

Source: Internet
Author: User

-- 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 ))

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.