Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Page History: DbIndexes View - SQL Server

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: Thu, May 11, 2023, 6:51 AM


create view dbo.DbIndexes as

select
     TableName = o.name
    ,IndexName = idx.Name
    ,ColumnNames = string_agg(c.name, ',') within group (order by c.name)
from
    sys.indexes idx
    inner join sys.tables o on idx.object_id = o.object_id
    inner join sys.index_columns ic on idx.index_id = ic.index_id and idx.object_id = ic.object_id
    inner join sys.columns c on ic.column_id = c.column_id and c.object_id = o.object_id
group by
    o.name
    ,idx.name

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.