Solution 1:
Select Table_name as “Table Without PK”
From Information_schema.Tables
Where Table_type = ‘BASE TABLE’ and
Objectproperty (Object_id(Table_name), ‘TableHasPrimaryKey’) = 0 and
Objectproperty (Object_id(Table_name), ‘IsUserTable’) = 1
Solution 2:
Select [name] as “Table Without PK”
from SysObjects where xtype=’U’ and
id not in
(
Select parent_obj from SysObjects where xtype=’PK’
)
Comments
Leave a comment Trackback