Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Script Library
 Useful index information

Author  Topic 

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-04 : 07:09:12
[code]SELECT i.Name AS IndexName,
t.Name AS TableName,
c.Name AS ColumnName,
sik.KEYNO AS ColumnPosition,
c.IS_IDENTITY AS IsIdentity,
c.IS_ROWGUIDCOL AS IsRowGuidCol,
CASE i.INDEX_ID
WHEN 0 THEN 'Heap'
WHEN 1 THEN 'Clustered index'
ELSE 'Nonclustered index'
END AS IndexType,
i.IS_UNIQUE AS [Unique],
i.IGNORE_DUP_KEY AS IgnoreDuplicateKey,
i.IS_PRIMARY_KEY AS IsPrimaryKey,
i.IS_DISABLED AS IsDisabled,
i.ALLOW_ROW_LOCKS AS AllowRowLocks,
i.ALLOW_PAGE_LOCKS AS AllowPageLocks
FROM sys.sysindexkeys AS sik
INNER JOIN sys.tables AS t ON t.object_id = sik.ID
INNER JOIN sys.columns AS c ON c.OBJECT_ID = sik.ID AND c.COLUMN_ID = sik.COLID
INNER JOIN sys.indexes AS i ON i.OBJECT_ID = sik.ID AND i.INDEX_ID = sik.INDID[/code]


E 12°55'05.25"
N 56°04'39.16"
   

- Advertisement -