Groups | Blog | Home
all groups > sql server (alternate) > august 2006 >

sql server (alternate) : MS-SQL Related



Dot Net Daddy
8/4/2006 8:17:38 PM
Hello,

What is uniqueidentifier as a data type?

Also what is the data type for setting unique STRINGS ((nchar,
nvarchar), for example to be used for emails and user names in a user
registration system).

SQL Server does not allow me set primary keys for columns where data
types are not INT.

Thanks in advance.
Stu
8/4/2006 8:34:44 PM
A uniqueidentifier is equivelent to a GUID, if you've ever used it in
any other programming language. As for SQL Server not allowing you to
use other data types than int, you must be misinterpreting the errror
message. What error message do you see?


[quoted text, click to view]
Erland Sommarskog
8/5/2006 12:00:00 AM
Dot Net Daddy (cagriandac@gmail.com) writes:
[quoted text, click to view]

A uniqueidentifier is a 128-bit value, which is generated in such a way
that it is guaranteed to be unique in the whole universe. (Well, at least
this planet.) They are not specific to SQL Server, but Windows has them
all over the place, but calls them GUIDs.

[quoted text, click to view]

Huh? You can use almost any data type for primary keys. Since a primary
key is an index, the total key size may not execeed 900 bytes, so you
cannot use things like text or nvarchar(MAX).


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
Dot Net Daddy
8/5/2006 4:49:27 AM
Great. It has done it. I was using nvarchar(MAX) as you told.

Now it is ok.

Thank you very much for your help guys.


[quoted text, click to view]
AddThis Social Bookmark Button