Link to home
Start Free TrialLog in
Avatar of sam2929
sam2929

asked on

how can i see relationship

Hi,
I have tables in sql server 2008 and that tables have 1-1 or 1-n relationship

lets say i have table x and table x has reationship to 5 other tables

how can i see that in some kind of  visio in sqlserver .

Thanks
Avatar of Camillia
Camillia
Flag of United States of America image

See screenshot

1.Sql Server Management Studio ->Object Explorer->Databases->Database Node
2. find a node named Database Diagrams
3.Right Click on "Database Diagrams" node and select new database diagram. You'll get a wizard.

User generated image
ASKER CERTIFIED SOLUTION
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

The simplest way, you right click on the table then choose View Dependencies -> Objects on which ... depends
User generated image
Another way, use script to find out FOREIGN KEY
SELECT t.[Table Name],
t.[Foreign Key Name],
t.[Parent Table],
t.[Referenced Column]
FROM (
SELECT
 '[' + SCHEMA_NAME(fk.[schema_id]) + '].[' + OBJECT_NAME(fk.parent_object_id) + ']' AS [Table Name]
,fk.name [Foreign Key Name]
,OBJECT_NAME(fk.referenced_object_id) [Parent Table]
,COL_NAME(fkc.referenced_object_id,fkc.referenced_column_id) AS [Referenced Column]
FROM sys.foreign_keys fk
   INNER JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id) t
--WHERE   t.[Table Name] =  N'[dbo].[FactFinance]'
ORDER BY [Table Name] ASC

Open in new window