Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server unique-identifier equivalent in C#

Tags:

What datatype should I use in C# to work with the SQL Server uniqueidentifier.

Do I need any conversions etc ?

like image 373
Asad Avatar asked Jan 27 '10 17:01

Asad


People also ask

What is a unique identifier SQL?

The globally unique identifier (GUID) data type in SQL Server is represented by the uniqueidentifier data type, which stores a 16-byte binary value. A GUID is a binary number, and its main use is as an identifier that must be unique in a network that has many computers at many sites.

What is GUID data type?

The GUID data type is a 16 byte binary data type. This data type is used for the global identification of objects, programs, records, and so on. The important property of a GUID is that each value is globally unique. The value is generated by an algorithm, developed by Microsoft, which assures this uniqueness.

Is Newid unique in SQL Server?

In assigning the default value of NEWID() , each new and existing row has a unique value for the CustomerID column.

How do I find the GUID in SQL Server?

Create a variable of uniqueidentifier data type. Type the below code in SSMS and execute. DECLARE @guid uniqueidentifier = NEWID(); SELECT @guid as 'GUID'; Here we created a variable named guid of data type uniqueidentifier.


1 Answers

System.Guid

No conversions needed.

like image 121
codekaizen Avatar answered Oct 20 '22 09:10

codekaizen