Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Viewing all articles
Browse latest Browse all 3160

SDU Tools: List Indexes in a SQL Server Database

$
0
0

When I'm working with a SQL Server database, I often need a simple list of all the indexes that are already in place. I want it in a concise form. In our free SDU Tools for developers and DBAs, we added a procedure ListIndexes to do just that, and to provide their details in a form that's easy to consume programmatically if you need that.

You can see how to execute it in the main image above. The procedure takes these parameters:

@DatabaseNamesysname This is the database to process

@SchemasToListnvarchar(max) a comma-delimited list of schemas to include (ie: 'Sales,Purchasing') or the word 'ALL'

@TablesToListnvarchar(max)- a comma-delimited list of tables to include (ie: 'Customers,Orders') or the word 'ALL'

One row is returned for each index.

The columns returned are SchemaName, TableName, IndexName, KeyColumnList, and IncludedColumnList as shown below:


SDU Tools: List Indexes in a SQL Server Database

You can see it in action here:

To become an SDU Insider and to get our free tools and eBooks, please just visit here:

http://sdutools.sqldownunder.com


Viewing all articles
Browse latest Browse all 3160

Trending Articles