I want to create a varchar column in SQL that should contain N'guid'
while guid
is a generated GUID by .NET (Guid.NewGuid) - class System.Guid.
What is the length of the varchar
I should expect from a GUID?
Is it a static length?
Should I use nvarchar
(will GUID ever use Unicode characters)?
varchar(Guid.Length)
PS. I don't want to use a SQL row guid data-type. I am just asking what is Guid.MaxLength
.
Binary strings store raw-byte data, whilst character strings store text. Use binary data when storing hexi-decimal values such as
SID
,GUID
and so on. The uniqueidentifier data type contains a globally unique identifier, or GUID. This value is derived by using the NEWID() function to return a value that is unique to all objects. It's stored as a binary value but it is displayed as a character string.Here is an example.
Applies to: SQL Server The following example creates the cust table with a uniqueidentifier data type, and uses NEWID to fill the table with a default value. In assigning the default value of NEWID(), each new and existing row has a unique value for the CustomerID column.