Sometimes it is useful to get all tables which has no primary key set.
With this short script you can get tables with a missing primary key even on SQL Server 2000.
USE myDatabaseGOSELECTso.NAME,so.CRDATEFROM sysobjects soWHEREso.xtype = 'U'AND so.NAME NOT IN (SELECTso.NAMEFROM sysobjects soinner join sysindexes si ONso.ID = si.IDWHEREso.xtype = 'U'AND si.indid = 1)ORDER BY NAME
Thanks Christian
AntwortenLöschenNice script for MS SQL. Amost identical to Oracle ones I often use. Just a question will it show table without primary keys and unique keys?
-- Kirill Loifman, dadbm.com