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 |
|
Pablo Javier
Starting Member
1 Post |
Posted - 2007-04-19 : 09:30:04
|
| Hi,I am working with Sql Server 2005.I have a Linked Server (to an Access database) from which I want to get the foreign keys of its tables.To do that I use the store procedure sp_foreignkeys.The problem is that in a table that I have two foreign keys to the same table, which are multicolumn keys, I can’t identify the keys with the result of the stored procedure because it returns first the records with KEY_SEQ=1 and then the records with KEY_SEQ=2, and in this records is impossible to solve to which relations they belong because there is not field identifying the relation.For example:TableAIdCol1IdCol2TableBFK1TableA_IdCol1FK1TableA_IdCol2FK2TableA_IdCol1FK2ItableA_IdCol2The relations are:Foreign Key Primary KeyTableB TableARelation1:FK1TableA_IdCol1 -> IdCol1FK1TableA_IdCol2 -> IdCol2Relation2:FK2TableA_IdCol1 -> IdCol1FK2TableA_IdCol2 -> IdCol2When i get the records from the stored procedure, it gives the following result:PKTABLE_NAME PKCOLUMN_NAME FKTABLE_NAME FKCOLUMN_NAME KEY_SEQTableA IdCol1 TableB FK1TableA_IdCol1 1TableA IdCol1 TableB FK2TableA_IdCol1 1TableA IdCol2 TableB FK1TableA_IdCol2 2TableA IdCol2 TableB FK2TableA_IdCol2 2The other fields are returned with NULL value.When I try to identify the keys, I can’t differentiate to which key the third record belongs, becouse there is no field identifying the relation, so I can’t know if it belongs to Relation1 or to Relation2. The same with the fourth record.Am I missing something that allow me to identify the relation?Is it a bug in the store procedure?Is there any other way to get the relations?Thanks in advance!Pablo |
|
|
|
|
|