Previous
Left Arrow
A SQL Server Script for Zip Codes.
Current Code Entry
Next
CFF Coding Source - 
Using SQL Server Management Studio to get a list of all tables and their Primary Keys
  • Using SQL Server Management Studio to get all tables with the same foreign key

    Article Entry Date: February 27,2026 @ 06:08:46 / Last Updated On: February 27,2026 @ 06:25:01
In [SQL Server], our Tables [Primary Key] are used in other tables. This is called a [Relational Database].
If, like me, you find you have too many tables to keep track of which Primary Key has been used in.
Using [SQL Server Management Studio] ([SSMS]), we can use this script to find all the tables that are using the same foreign key.

Replace the 'MyTableID' with the ID you need to find the tables for.

To find all Table Names and their [Primary Key], use the article below to learn more.▼

Other Articles Related to this Entry.


Using SQL Server Management Studio to get a list of all tables and their Primary Keys«