Wednesday, March 7, 2012

find indexes

I'm a new user of SQL Server.
What's the script to find out all indexes for tables and
views?
Thanks.Hi,
sp_helpindex <table name or view name>
You can also use the below statement to get all the information of the
object (including index).
sp_help <table or view name>
Thanks
Hari
MCDBA
"Julia" <KQD02@.YAHOO.COM> wrote in message
news:143d001c444cd$ab9aa640$a601280a@.phx.gbl...
> I'm a new user of SQL Server.
> What's the script to find out all indexes for tables and
> views?
> Thanks.|||Thanks, is it possible to get all indexes for all tables
and views in one script?
>--Original Message--
>Hi,
>sp_helpindex <table name or view name>
>You can also use the below statement to get all the
information of the
>object (including index).
>sp_help <table or view name>
>Thanks
>Hari
>MCDBA
>
>"Julia" <KQD02@.YAHOO.COM> wrote in message
>news:143d001c444cd$ab9aa640$a601280a@.phx.gbl...
>> I'm a new user of SQL Server.
>> What's the script to find out all indexes for tables and
>> views?
>> Thanks.
>
>.
>|||Hi,
Execute the below script in query analyzer
Use dbname
go
select substring(a.name,1,20) as Table_View_name,substring(b.name,1,20) as
Index_name,type as Object_type,indid
from sysobjects a, sysindexes b
where a.id=b.id
and type in ('U','V')
and indid between 1 and 254
-- If indid = 1 then Clustered index
-- indid >1 then Nonclustered index
Thanks
Hari
MCDBA
Julia" <anonymous@.discussions.microsoft.com> wrote in message
news:1443901c444d2$9074c850$a301280a@.phx.gbl...
> Thanks, is it possible to get all indexes for all tables
> and views in one script?
>
> >--Original Message--
> >Hi,
> >
> >sp_helpindex <table name or view name>
> >
> >You can also use the below statement to get all the
> information of the
> >object (including index).
> >
> >sp_help <table or view name>
> >
> >Thanks
> >Hari
> >MCDBA
> >
> >
> >"Julia" <KQD02@.YAHOO.COM> wrote in message
> >news:143d001c444cd$ab9aa640$a601280a@.phx.gbl...
> >> I'm a new user of SQL Server.
> >> What's the script to find out all indexes for tables and
> >> views?
> >> Thanks.
> >
> >
> >.
> >

No comments:

Post a Comment