In [
SQL Server Management Studio] ([
SSMS]), we can use a script to obtain all tables' primary keys. This will come in handy if you have a lot of tables and need to find the relationship between the tables using their [
Primary Key].
In SSMS, open a New Query editor.
Copy and paste this code into the editor.
Next, press [
Execute] or [
F5] to run the script.
The outcome will give results similar to this, using our Virtual Class Database.
Once you have this information, you might want to check each Primary Key to find what tables it is used in as a Foreign Key to that table. Use the article below to learn more.▼