MS SQL Server Concepts and Programming Question:
Download Questions PDF

How To View Existing Indexes on an Given Table using sys.indexes?

Answer:

Another way to view existing indexes defined for a given table is to use the system view called "sys.indexes". The tutorial exercise shows you how many indexes were defined from the previous tutorial on table "ggl_links":

USE GlobalGuideLineDatabase;
GO

SELECT * FROM sys.indexes WHERE object_id = (
SELECT object_id FROM sys.tables WHERE name = 'ggl_links'
);
GO
<pre>object_id name index_id type_desc is_unique
--------- ------------- -------- ---------- ---------
421576540 NULL 0 HEAP 0
421576540 ggl_links_id 2 NONCLUSTERED 0
421576540 ggl_links_url 3 NONCLUSTERED 0</pre>
The extra line in the query result is not a real index at this moment. It will be explained in another tutorial.

Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
How To View Existing Indexes on an Given Table using SP_HELP?How To Drop Existing Indexes in MS SQL Server?