Unique/primary key on 2 uniqueidentifier column | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Unique/primary key on 2 uniqueidentifier column

Hi Folks, Got stucked in a rare situation, I have a table with 4 columns ;id1 ,id2 are uniqueidentifier (16),
uniqueidentifier (16) resp. We need to create unique/primary key constraint using these 2 columns ,
How can I do this. Is my situation is a normal situation.
Thanks in advance
Either column should already be unique. To add a constraint that forces the combination of the two to be unique is therefore futile.
Why would either column already be unique?? If these are foreign keys, that would not be so. I make composite primary keys from multiple uniqueidentifier columns all the time, in associative tables. You can either create a primary key that consists of both these columns, or create a unique constraint on both columns. The only difference is that by default the primary key will have be a clustered index. -Greg
Unique constraints allow one NULL value where as PK doesn’t…
MohammedU.
Moderator
SQL-Server-Performance.com All postings are provided “AS IS” with no warranties for accuracy.

GUIDs generated by NEWSEQUENTIALID() are unique only within a particular computer if the computer does not have a network card, if this is a standalone machine with no NIC then you could create GUIDs that match GUIDs created on another machine. Relevant information on available:
http://www.informit.com/articles/article.asp?p=25862&seqNum=1&rl=1
http://www.styledesign.biz/weblogs/macinnesm/archive/2004/09/14.aspx
http://groups.google.com/group/microsoft.public.sqlserver.programming/browse_thread/thread/73ba34c9d1b0cd53/
http://spaces.msn.com/drsql/blog/cns!80677FB08B3162E4!416.entry Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
This posting is provided AS IS with no rights for the sake of knowledge sharing. The greatest discovery of my generation is that a human being can alter his life by altering his attitudes of mind.
]]>