How to know a column whether indexed or not in sql2k

  • Thread starter Thread starter joy.net
  • Start date Start date
First, it is not wise to only have a subject, as your question can get cut
off and, therefore, never answered. Best to put the question in the body,
even if it is a repeat.

To find columns, you use the system tables (or Sys views: SQL Server 2005).
I do not have a query for this, however. The SQL Server Programming group is
the best shot for this; Aaron Bertrand's ASPFAQ.com site may have an answer,
as well (Aaron is a SQL Server MVP).

In a more generic way, you can use SQL-DMO, but this involves interop with
..NET. There is also an ADO library (ADOX, I believe) that will work against
multiple types of databases; it is also Interop.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
1) Use the system stored procedure sp_help and pass it the name of the table
which contains the column that you're interested in.

2) Look for the column name in the index_keys column of the sixth
resultset - if it's there, the column participates in a least one index.
 
Or use the new 2.0 GetSchema method on the Connection.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top