sql - Finding columns that do not match existing primary key -
I am trying to add a foreign key to a table, but the database does not like it, SQL Server 2005, it does not like it.
It says that columns do not match existing primary key or unique constraints.
How do I get a column in questions so that I can delete or change them and add foreign keys?
Join a left in the parent table on the question, then check the values in the child's table where Join the left parent's table is zero. For example, if this was your schema ...
table1: myKey int primary key, ... other columns ... Table 2: Other Key difference primary key, myKeyFromTable1 int ... other columns ..
you want to do this:
separate t2.myKeyFromTable1 from table 2 t2
This will give you a special value in table2
which is left in the table 1 t1 on t1.myKey = t2.myKeyFromTable1 table1 < There will be no related parents with / code>.
Comments
Post a Comment