SQLUSA

Microsoft SQL Server 2005 Best Practices

Microsoft SQL Server 2000 Best Practices

How to find unique indexes in a database?

 

The following query will list unique indexes which are not primary keys:

use DatabaseX

select IndexName=Name, [Table] = object_name(id)
from sysindexes where status & 2 = 2
and ID not in (select parent_obj from sysobjects where xtype='PK')
and ID in (select id from sysobjects where xtype='U')

 

The Best SQL Server Training in the World
The future is just a click away! Your Future!
SQLUSA.com Home Page