[ACCEPTED]-How do you list all the indexed views in SQL Server?-indexed-view
Accepted answer
SELECT o.name as view_name, i.name as index_name
FROM sysobjects o
INNER JOIN sysindexes i
ON o.id = i.id
WHERE o.xtype = 'V' -- View
0
I like using the newer system tables:
select
OBJECT_SCHEMA_NAME(object_id) as [SchemaName],
OBJECT_NAME(object_id) as [ViewName],
Name as IndexName
from sys.indexes
where object_id in
(
select object_id
from sys.views
)
The 1 inner join version
select
OBJECT_SCHEMA_NAME(si.object_id) as [SchemaName],
OBJECT_NAME(si.object_id) as [ViewName],
si.Name as IndexName
from sys.indexes AS si
inner join sys.views AS sv
ON si.object_id = sv.object_id
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.