SQL Server administration and T-SQL development, Web Programming with ASP.NET and Javascript, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software Kodyaz Development Resources
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Vista, etc.


sysindexes System View - List of Indexes Defined on a SQL Database Table


SQL developers and SQL Server database administrators frequently require to list of indexes defined on a sql database table.
Any in many cases list indexes and fields of indexes defined on a sql table are necessary for building generic database applications for sql developers.

In MS SQL Server 2005 and later versions (SQL Server 2008, SQL Server 2008 R2), t-sql developers and sql administrators can use below t-sql select script in order to list SQL Server indexes defined for a sql table.
The given t-sql sample runs a SELECT statement on sys.indexes table (in fact sys.indexes system view) with Object_Id of the sql table is in the WHERE criteria.

SELECT
  object_id,
  name,
  index_id,
  type,
  type_desc,
  is_unique,
  data_space_id,
  ignore_dup_key,
  is_primary_key,
  is_unique_constraint,
  fill_factor,
  is_padded,
  is_disabled,
  is_hypothetical,
  allow_row_locks,
  allow_page_locks,
  has_filter,
  filter_definition
FROM sys.indexes
WHERE
  object_id = object_id('HumanResources.Employee')




Here is the sample output of the tsql select statement on sysindexes table (or sys.indexes system view).

sql-server-sysindexes-system-view-for-index-on-table







Related SQL Resources

SQL Server Articles

SQL Server 2012

SQL Server Tools

SQL Blog

SQL Server 2008 Blog

Certification Exams Blog

Reporting Services Blog

Analysis Services Blog

MS SQL Server Forums



Free Exam Vouchers









Copyright © 2004 - 2012 Eralper Yilmaz. All rights reserved.
Community Server, by Telligent Systems