I am looking for a transact sql that will allow me to view all the indexes i
n
a database without viewing them on a table by table basis.What about
Select * from sysindexes ?
Or use the INFORMATION_SCHEMA Views.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Aboki" <Aboki@.discussions.microsoft.com> schrieb im Newsbeitrag
news:B7AE0AE2-1FBB-4486-BBA5-9512F7AEE9FA@.microsoft.com...
>I am looking for a transact sql that will allow me to view all the indexes
>in
> a database without viewing them on a table by table basis.|||You can use the undocumented sp sp_msforeachtable or create a cursor to
traverse information_schema.tables and execute for each table the sp
sp_helpindex, or as recommended by Jens, select from system table
"sysindexes".
Example:
use northwind
go
exec sp_msforeachtable 'select ''?'' as [table_name]; exec sp_helpindex
[?]'
go
AMB
"Aboki" wrote:
> I am looking for a transact sql that will allow me to view all the indexes
in
> a database without viewing them on a table by table basis.|||SELECT 'dbcc showcontig (' +
CONVERT(varchar(20),i.id) + ',' + -- table id
CONVERT(varchar(20),i.indid) + ') -- ' + -- index id
object_name(i.id) + '.' + -- table name
i.name -- index name
from sysobjects o
inner join sysindexes i
on (o.id = i.id)
where o.type = 'U'
and i.indid < 2
and
i.id = object_id(o.name)
ORDER BY
object_name(i.id), i.indidsql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment