Solved

sql server Foreign Key to a GUID

Posted on 2014-09-12
3
236 Views
Last Modified: 2014-09-12
I have two tables, tblpeople and tbladdresses.  Both have a PersonID, in tblpeople that id is a Primary Key data type GUID.  In the tbladdresses it is a varchar, but has the same info from tblpeople but there are duplicates due to multiple addresses.  I am trying to get a foreign key reference but it is complaining about the data type issue.  What is the best way to fix this?
0
Comment
Question by:gwarcher
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
Brian Crowe earned 500 total points
Comment Utility
I would recommend changing the datatype of the tblAddresses column to UNIQUEIDENTIFIER.  The datatype name "uniqueidentifier" does not mean that the value must be unique within the table.
0
 

Author Comment

by:gwarcher
Comment Utility
I was not aware of that.  Thank you.  I thought it had to be unique.
0
 
LVL 34

Expert Comment

by:Brian Crowe
Comment Utility
It just means that it s intended to be globally unique so that if you execute NEWID() on multiple machines at the same time and/or the same machine multiple times you are "guaranteed" to get unique values in each case.  Actually this isn't 100% true but it is generally "true enough".
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now