[ACCEPTED]-How to make Database Diagram visually show Foreign Keys in Management Studio?-ssms
I know this is an old post but this may 18 help others.
within SSMS Database Diagram 17 by right-clicking a table > then select 16 "table view" > then select "keys" this will 15 only show PK and FK and all other keys in 14 that table. OK you say you need it on all 13 tables that's fine in within SSMS Database 12 Diagram click the background (with no items 11 selected) then press "Ctrl+A" to select 10 all then with your mouse over a selected 9 table right-clicking > then select "table 8 view" > then select "keys" this will show 7 PK and FK and all other keys in each selected 6 tables. then if you need to see the full 5 set of column names for a given table you 4 can change the "table view" for that one 3 and change it back.
This way you see what 2 has and what has not got FK ...
Hope this 1 helps others like it has me.
In SSMS, if you expand the tree of tables 16 for your database, then expand the Columns 15 folder, the icon next to a column will be 14 a silver/gray key if it's part of a foreign 13 key relationship, but unfortunately it won't 12 show you the column to which column it's 11 mapped.
You could also create a new diagram 10 in SSMS by right-clicking the "Database 9 Diagrams" folder underneath your database 8 in the tree and choosing "New Database Diagram." You 7 will get lines between the tables where 6 foreign keys exists.
You could also use third-party 5 tools to reverse engineer a diagram from 4 your DB schema, like Microsoft Visio or 3 Sparx Enterprise Architect.
I'm not sure 2 SSMS Express supports these things, so you 1 might be out of luck with anything fancy/visual.
I have not found a way to do it visually 3 in the Management Studio but you can try 2 the following:
select f.name as ForeignKey, OBJECT_NAME(f.parent_object_id) as TableName, COL_NAME(fc.parent_object_id, fc.parent_column_id) AS ColumnName, OBJECT_NAME (f.referenced_object_id) AS ReferenceTableName, COL_NAME(fc.referenced_object_id, fc.referenced_column_id) AS ReferenceColumnName from sys.foreign_keys f inner join sys.foreign_key_columns fc ON f.OBJECT_ID = fc.constraint_object_id
this is not visual but you 1 will be faster to check
More Related questions