create procedure psp_help_allidx7
as
/* Purpose: to list all indexes for each table
Author : Eddy Djaja, Publix Super Markets, Inc.
Revision: 12/07/1999 born date
*/
-- SET UP SOME CONSTANT VALUES FOR OUTPUT QUERY
declare @empty varchar(1)
select @empty = ''
declare @des1 varchar(35), -- 35 matches spt_values
@des2 varchar(35),
@des4 varchar(35),
@des32 varchar(35),
@des64 varchar(35),
@des2048 varchar(35),
@des4096 varchar(35),
@des8388608 varchar(35),
@des16777216 varchar(35)
select @des1 = name from master.dbo.spt_values where type = 'I' and number = 1
select @des2 = name from master.dbo.spt_values where type = 'I' and number = 2
select @des4 = name from master.dbo.spt_values where type = 'I' and number = 4
select @des32 = name from master.dbo.spt_values where type = 'I' and number = 32
select @des64 = name from master.dbo.spt_values where type = 'I' and number = 64
select @des2048 = name from master.dbo.spt_values where type = 'I' and number = 2048
select @des4096 = name from master.dbo.spt_values where type = 'I' and number = 4096
select @des8388608 = name from master.dbo.spt_values where type = 'I' and number = 8388608
select @des16777216 = name from master.dbo.spt_values where type = 'I' and number = 16777216
select o.name,
i.name,
'index description' = convert(varchar(210), --bits 16 off, 1, 2, 16777216 on, located on group
case when (i.status & 16)<>0 then 'clustered' else 'nonclustered' end
+ case when (i.status & 1)<>0 then ', '+@des1 else @empty end
+ case when (i.status & 2)<>0 then ', '+@des2 else @empty end
+ case when (i.status & 4)<>0 then ', '+@des4 else @empty end
+ case when (i.status & 64)<>0 then ', '+@des64 else
case when (i.status & 32)<>0 then ', '+@des32 else @empty end end
+ case when (i.status & 2048)<>0 then ', '+@des2048 else @empty end
+ case when (i.status & 4096)<>0 then ', '+@des4096 else @empty end
+ case when (i.status & 8388608)<>0 then ', '+@des8388608 else @empty end
+ case when (i.status & 16777216)<>0 then ', '+@des16777216 else @empty end),
'index column 1' = index_col(o.name,indid, 1),
'index column 2' = index_col(o.name,indid, 2),
'index column 3' = index_col(o.name,indid, 3)
from sysindexes i, sysobjects o
where i.id = o.id
and indid > 0
and indid < 255
and o.type = 'U'
--exclude autostatistic index
and (i.status & 64) = 0
and (i.status & 8388608) = 0
and (i.status & 16777216)= 0
order by o.name
go
exec psp_help_allidx7
go
[출처] DB상의 모든 인덱스 정보를 보이는 저장프로시져 |작성자 필립박
'데이터베이스 > SQL Server' 카테고리의 다른 글
[MsSql] table schema 출력하는 procedure (0) | 2008.04.28 |
---|---|
MSSQL 링크드서버를 이용하여 오라클 데이타 이용 (0) | 2008.04.28 |
Bulk Insert 옵션에 따른 성능 비교 (0) | 2008.04.28 |
인덱스의 사용량 (0) | 2008.04.28 |
사용안된 index 목록 뽑아내기 (0) | 2008.04.28 |