Last post Jan 08, 2014 04:52 AM by jayakumarvinayagam
Jan 07, 2014 01:41 PM|jayakumarvinayagam|LINK
I had created a site, it contain's user registration form data, then I store in DB (SQL server 2008), I have to store each and every user data in some unique id,
for example 6c0f6347-7957-4349-87ff-255bbdc6b027, a7ed667b-29cc-4458-8d2d-ff4c8fa70428, e88bf2ff-6972-4bbe-b8c9-59660d9f08a6, etc.
So which data type is best for the table column. how I generate this type of series of numbers/characters.
Thansk for your time.
Jan 07, 2014 04:24 PM|AZMatt|LINK
In SQL, use the uniqueidentifier data type. Just leave it out of your INSERT statements, and it will automatically generate a new value.
In VB or C#, use the GUID data type.
Jan 07, 2014 05:25 PM|Rion Williams|LINK
As AZMatt mentioned, this particular pattern is referred to as a "GUID" or Globally-Unique-Identifier and it is perfect for using when you need an absolutely unique identifier for something.
The data type that you use should for a SQL column that is going to store a GUID is a
uniqueidentifier and the cooresponding .NET data type is a
A Guid can easily be generated by using the available
Guid.NewGuid() static method as seen below :
//Generate a Guid
Guid userGuid = Guid.NewGuid();
Jan 08, 2014 04:52 AM|jayakumarvinayagam|LINK
Thanks you for putting extra mile on that.