Globally Unique Identifier newsequentialid ()

Source: Internet
Author: User

----------------------------------------------------------------------------------

-- Blog: http://blog.csdn.net/htl258

-- Subject: describes the Globally Unique Identifier newsequentialid introduced by sql2005.

----------------------------------------------------------------------------------

-- The newsequentialid () function returns the uniqueidentifier of each byte. The main difference with newid () is:

-- Newsequentialid (): The new value is greater than the value generated last time. Unlike newid (), this function cannot

-- Called directly in the query. It can only be 'uniqueidentifier' In the create table statement or alter table statement'

-- Used in the default expression of a column of the type.

 

--> Generate a test data table: [TB]

If object_id ('[TB]') is not null

Drop table [TB]

Go

Create Table [TB] (ID uniqueidentifier default newsequentialid (), [a] [int], [B] [int])

Insert into [TB] ([a], [B])

Select '1', '2' Union all

Select '2', '3' Union all

Select '4', '5'

 

Select * from [TB]

/*

ID a B

----------------------------------------------------------

8783e9b7-2c5d-df11-a05c-001cbf7c5a9c 1 2

8883e9b7-2c5d-df11-a05c-001cbf7c5a9c 2 3

8983e9b7-2c5d-df11-a05c-001cbf7c5a9c 4 5

 

(3 rows affected)

*/

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/htl258/archive/2010/05/12/5580900.aspx

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.