SQL Server: Script to find all the Tables without having a Primary Key

In this post, I am providing a script to find all the tables without having a Primary Key in a database of SQL Server.

This script is very important because Primary Key is a one of a major part of the table. I never recommended to create a table without Primary Key and even at this stage not require to explain the importance of Primary Key.

You can visit this article for more details:

Best practice for Primary Key in Database Management System

Using this script, I have found all the tables that do not have a primary key and which are created by another database development team So for me this is time to add missing Primary Keys.

Below is a two different script to find missing Primary Keys:

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of