June 14, 2005 at 10:19 pm
Hi,
How do I find out which tables contain unique indexes and which tables contain non-unique indexes? And is this documented anywhere?
Thanks a lot!
June 15, 2005 at 12:28 am
If you just want to check for a single table then sp_helpindex is best. However, if you want a query to return this information for all tables at once, here is something to start with:
SELECT OBJECT_NAME([id]) AS tablename
, [name] AS indexname
, INDEXPROPERTY([id], [name], 'IsUnique') AS IsUnique
FROM sysindexes
June 15, 2005 at 12:50 am
thanks very much, this helps.
June 15, 2005 at 3:09 pm
Np, happy to help. And in SQL Server 2005, it is even easier:
SELECT OBJECT_NAME(object_id) AS tablename
, [name] AS indexname
, is_unique
FROM sys.indexes
The new catalog views for metadata are really great with a lot more information than we had before.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply