Happy Coding!!
Some times you are analyzing the database to check which tables don't have primary keys then in that case follwing query will help you to find out the tables:
Below SQL will give you the list of table in you Database not having Primary Keys.
Below SQL will give you the list of table in you Database not having Primary Keys.
SELECT SCHEMA_NAME(schema_id) AS SchemaName,name AS TableNameFROM sys.tablesWHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') = 0ORDER BY SchemaName, TableName;
Happy Coding!!
No comments:
Post a Comment