Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with creating relationships
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

17 Posts

Posted - 11/19/2012 :  11:20:39  Show Profile  Reply with Quote
I have two table both with a column named TypeID.

Paths <-table
TypeID (int, 4, primary key = no, identity = false)

Types <-table
TypeID (int, 4, primary key = yes, identity = true)

This is a SQL compact DB that I'm editing through Visual Studio. When I try and make a relationship between the two tables via the TypeID columns I get the following error.

"Add Relation failed. Parent Columns and Child Columns don't have type-matching columns."

Both are int with length 4, what could be causing this error?

Flowing Fount of Yak Knowledge

6065 Posts

Posted - 11/19/2012 :  11:56:01  Show Profile  Reply with Quote
I don't have too much to offer here but since no one else is chiming in -
Perhaps VS's schema is out of sync with the actual database or maybe pointing to a different db instance?

But being a long term sql server developer I only use Management Studio for this. For instance to create this "relationship" I would use a query window to issue this command:

alter table Paths add constraint FK_Paths_Types foreign key (TypeID) references Types (TypeID)

Can Sql Compact be used in SSMS?

Be One with the Optimizer
Go to Top of Page

Flowing Fount of Yak Knowledge

7174 Posts

Posted - 11/19/2012 :  12:54:29  Show Profile  Reply with Quote
I think it might be due to identity column. Do you have some value in child table(Primary Key) which doesn't exist in Parent table?
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000