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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
The simplest way, you right click on the table then choose View Dependencies -> Objects on which ... depends
Another way, use script to find out FOREIGN KEY
The simplest way, you right click on the table then choose View Dependencies -> Objects on which ... depends
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
1.Sql Server Management Studio ->Object Explorer->Databases->Datab
2. find a node named Database Diagrams
3.Right Click on "Database Diagrams" node and select new database diagram. You'll get a wizard.