Pages

Sunday, September 15, 2013

SQL SERVER – 2005 – List Tables in Database Without Primary Key | Journey to SQL Authority with Pinal Dave

This is very simple but effective script. It list all the table without primary keys. USE DatabaseName; GO SELECT SCHEMA_NAME(schema_id) AS SchemaName,name AS TableName FROM sys.tables WHERE OBJECTPROPERTY(OBJECT_ID,'TableHasPrimaryKey') = 0 ORDER BY SchemaName, TableName; GO Reference : Pinal Dave (http://blog.SQLAuthority.com), BOL Continue Reading...

Source: SQL SERVER – 2005 – List Tables in Database Without Primary Key | Journey to SQL Authority with Pinal Dave

No comments:

Post a Comment