There are those indexes in the SQL query table

Source: Internet
Author: User

Method 1. Working with system tables

--Query indexes and index columns in a table use adventureworks2008goselect  indexname = a.name, TableName = c. name, Indexcolumns = d. Name, A. Indidfrom    sysindexes A join Sysindexkeys B on a. id = B. ID and  a. indid = B.indid        JOIN sysobjects C on B. Id = c. ID        JOIN syscolumns d on b. ID = d. ID and  b. colid = d. colidwhere   A. Indid not in (0, 255)  --and   c.xtype= ' U '   and   c.status>0--Check all user tables and C. name = ' DatabaseLog '--Check the specified table order by C. Name,        A.name, 
   d.name

Method 2. Using System stored Procedures

Sp_helpindex: Reports information about indexes on a table or view.

  /* Sp_helpindex [@objname =] ' name ' parameter: [@objname =] ' name ' is the name of the table or view in the current database. The data type of name is nvarchar (776) and has no default value. */use db_namegosp_helpindex ' Tablename '

Returns the code value 0 (success) or 1 (failed) result set:

Column Name

Data type

Describe

Index_name

sysname

The index name.

Index_description

varchar (210)

The index description.

Index_keys

nvarchar (2078)

A table or view column that constructs an index on these columns.

Columns that are indexed in descending order are listed in the result set with a minus sign (-) followed by the name of the column (which is the default) when the column is listed in the ascending index. Note This information is displayed in the sp_helpindex result set if the index has been set with the NoRecompute option of UPDATE STATISTICS.

There are those indexes in the SQL query table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.