Click here to Skip to main content
15,905,071 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Sir,

I heared about GUID and I kind of understood that its a data type , But I couldn't use it

could you please show me the way to use it ...

by the way , lets say I want something like this :

SQL
CREATE TABLE Employees ( ID guid PRIMARY KEY, Name NVARCHAR(50) NOT NULL )
Posted
Updated 28-Dec-11 22:14pm

The data type for guid is uniqueIdentifier so your DDL should be something like:
SQL
CREATE TABLE Employees ( ID uniqueidentifier PRIMARY KEY, Name NVARCHAR(50) NOT NULL ).


See: uniqueidentifier (Transact-SQL)[^]
 
Share this answer
 
Comments
Prashant Srivastava LKO 29-Dec-11 4:19am    
Thanks for Guidance Sir
Wendelius 29-Dec-11 5:03am    
You're welcome :)
RaisKazi 29-Dec-11 6:07am    
My 5.
Wendelius 29-Dec-11 6:29am    
Thanks :)
Hi,

you can generate unique GUID using
SQL
select NEWID();
from SQL server 2008. and using uniqueIdentifier datatype you can store it (as Mike said)

thanks
-amit.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900