Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ron2112
Starting Member
44 Posts |
Posted - 2011-08-04 : 09:31:25
|
When trying to create a foreign key, SQL Server 2005 is telling me the primary key on one of my tables does not match an existing primary key... What am I not understanding here?thanks!ron |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-04 : 09:34:41
|
seems like you already have pk constraint. try dropping and recreating the pk.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
ron2112
Starting Member
44 Posts |
Posted - 2011-08-04 : 09:49:00
|
quote: Originally posted by visakh16 seems like you already have pk constraint. try dropping and recreating the pk.
That's not entirely practical, as there are a number of existing FKs that use this PK, and I would have to go through the process of dismantling them all first, then rebuilding them afterwards. Why those FKs recognize this as a PK and the one I'm trying to create doesn't... I have no idea.ron |
 |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-08-04 : 10:40:13
|
What's the exact definition of the primary key (go and script the constraint)--Gail ShawSQL Server MVP |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2011-08-04 : 10:50:05
|
Are the datatypes same for the columns in both the tables ?PBUH |
 |
|
ron2112
Starting Member
44 Posts |
Posted - 2011-08-04 : 11:13:01
|
quote: Originally posted by GilaMonster What's the exact definition of the primary key (go and script the constraint)
This gave me the answer. The two fields are in the PK in the opposite order than I'd assumed. When I reversed the order of the fields in the FK, SQL Server accepted it with no complaints.Thank you, I'll keep this in mind for next time.ron |
 |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-08-04 : 11:28:29
|
Exactly what I suspected. Glad it's fixed.--Gail ShawSQL Server MVP |
 |
|
|
|
|