A colleague just forwarded me this little script for tracking down SQL Server database tables which don't have a primary key assigned. It's cute and useful, so I thought I'd blog it, as much for my own archiving purposes as for anything else
Use <databasename> -- where <databasename> is the name of your database
Go
select o.name from sysobjects o
join sysindexes i on o.id=i.id
where o.type ='u' -- user table
and i.indid=0 -- no index
order by o.name
Go
enjoy
posted @ Monday, October 30, 2006 1:38 PM