Sometime back I had done a post called Find all tables in a database without a primary key where I used the INFORMATION_SCHEMA.TABLES.
Megan commented asking how to rewrite the same query using sys.objects. Well here it is!
SELECT name as [TableName], create_date
WHERE type = 'U'
AND OBJECTPROPERTY([object_id], 'TableHasPrimaryKey') = 0;
If you do not get any results, then all your tables in your database have primary keys
You may also want to check the following related posts written some time ago:
Did you like this post?
|subscribe via rss||subscribe via e-mail|
|print this post||follow me on twitter|