Domanda

There is a database online that I was able to download. It came in Access, I exported it to SQL Server. It works beautifully. However when I create a diagram, it doesn't show the relationships. By that I mean I would like to see a line connecting the foreign keys from each table.

My google searches have been unsuccessful. Some say select relationship labels. That does not work. I do know that if I created a database, the tables, the keys etc, I would see the line I am looking for. Any reason why they are not showing up in this particular case? I have tried in both SQL Server 2008 R2 on Win 7 and 2012 on win 8. Same problem.

È stato utile?

Soluzione

Run this query to make sure some FK exists:

SELECT 
  [ForeignKey] = f.name
, [TableName] = OBJECT_NAME(f.parent_object_id), COL_NAME(fc.parent_object_id,fc.parent_column_id)
, [ReferenceTableName] = OBJECT_NAME (f.referenced_object_id)
, ReferenceColumnName = COL_NAME(fc.referenced_object_id, fc.referenced_column_id)
FROM 
sys.foreign_keys AS f
INNER JOIN sys.foreign_key_columns AS fc ON f.OBJECT_ID = fc.constraint_object_id
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top