by kimberly.nospam@nospam.sqlskills.com (admin) via Kimberly L. Tripp on 8/24/2008 1:23:29 PM
I first posted an update to sp_helpindex here. My version of sp_helpindex was solely to expand what sp_helpindex showed and adds 1 or 2 things based on version: for SQL2005+ it adds included columns and for SQL2008 it also adds the filter predicate. So, there were two versions of sp_helpindex2 depending on which verison you're using. A lot of folks like the changes to this sp but, alas, it had a bug (or two :) and in fact, I found a few others when I went back over this as well. So, thanks to Josh (who commented here) and to a private email (thanks Vasco!), I have an updated version of sp_helpindex2:
For SQL Server 2005, here's your new sp_helpindex2 script: sp_helpindex2_2005.zip (2.89 KB)
And, here's a simple test script for 2005:
DROP
CREATE
sp_helpindex2 tbl1go
index_name
index_description
index_keys
included_columns
ix_1
nonclustered located on fg1
c1
c2
ix_2
NULL
ix_3
c2, c3
ix_4
c1, c3
ix_5
c3
c1, c2, c4
ix_6
c1, c2
c3, c4
For SQL Server 2008, here's your new sp_helpindex2 script: sp_helpindex2_2008.zip (2.84 KB)
And, here's a simple test script for 2008:
CREATE INDEX ix_1f ON tbl1(c1) INCLUDE (c2)WHERE c3 IS NOT NULLCREATE INDEX ix_2f ON tbl1(c1) WHERE c4 > 2
index_name index_description index_keys included_columns filter_definition ix_1 nonclustered located on PRIMARY c1 c2 NULL ix_1f nonclustered located on PRIMARY c1 c2 ([c3] IS NOT NULL) ix_2 nonclustered located on PRIMARY c1 c2 NULL ix_2f nonclustered located on PRIMARY c1 c2 ([c4]>(2)) ix_3 nonclustered located on PRIMARY c1 c2, c3 NULL ix_3f nonclustered located on PRIMARY c1 c2, c3 ([c4]>(2) AND [c1]<(50) AND [c2]=(12)) ix_4 nonclustered located on PRIMARY c1, c3 c2 NULL ix_4f nonclustered located on PRIMARY c1, c3 c2 ([c4] IS NOT NULL AND [c1]=(12)) ix_5 nonclustered located on PRIMARY c3 c1, c2, c4 NULL ix_5f nonclustered located on PRIMARY c3 c1, c2, c4 ([c1]>(5)) ix_6 nonclustered located on PRIMARY c1, c2 c3, c4 NULL ix_6f nonclustered located on PRIMARY c1, c2 c3, c4 ([c4]<(20))
filter_definition
nonclustered located on PRIMARY
ix_1f
([c3] IS NOT NULL)
ix_2f
([c4]>(2))
ix_3f
([c4]>(2) AND [c1]<(50) AND [c2]=(12))
ix_4f
([c4] IS NOT NULL AND [c1]=(12))
ix_5f
([c1]>(5))
ix_6f
([c4]<(20))
Have fun!kt
Original Post: Updates (fixes) to sp_helpindex2
The content of the postings is owned by the respective author. SQL Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on SQL Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.