CODE:List tables with no primary key – SQL Server 2000

SELECT

DB_NAME() AS [Database],

T.TABLE_NAME AS [Tables without Primary Keys]

FROM INFORMATION_SCHEMA.TABLES AS T

WHERE NOT EXISTS

(SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC

WHERE CONSTRAINT_TYPE = ‘PRIMARY KEY’

AND T.TABLE_NAME = TC.TABLE_NAME)

AND T.TABLE_TYPE = ‘BASE TABLE’