Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Locate primary key - foreign key relations

By Mohit Nayyar,

Recently one of my friend was doing some investigation in a new/unknown database and had really hard time locating the primary key – foreign key relations.

Like it’s really tough to locate these relations when not enforced at database level in terms of primary key and foreign key constraints. But generally all database developers keep the same column names in a database solution and my script is also based on this assumption.

This script will simply search the given column name in all the tables and will also show the relationship (Primary Key / Foreign key) of this column with columns in other tables.

Thanks
Mohit Nayyar
http://mohitnayyar.blogspot.com/

Total article views: 2708 | Views in the last 30 days: 7
 
Related Articles
FORUM

Primary-Foreign Key

Primary-Foreign Key

SCRIPT

Effectively mapping primary key – foreign key relations

This script maps the primary key - foreign key relations regardless if the column names are the same...

FORUM

Primary and foreign keys

Can a primary key be a foreign key too?

FORUM

working with primary key column

working with primary key column

SCRIPT

The Ultimate Foreign Key Researcher

Searches for actual and potential foreign key columns for a given primary key reference.

Tags
 
Contribute