|
sql
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to avoid creating duplicate indexes on the same columnBefore creating an index on a table column, how to check if that column
was already indexed (with a different index name)? I have to do this in SQL Script. Thanks, Sarah Hello,
Just run SP_HELP or SP_Helpindex on that table and see. if the specific column is already indexed Thanks Hari Show quoteHide quote "Sarah Bram" <sarahb***@hotmail.com> wrote in message news:OUCqLX0ZHHA.4220@TK2MSFTNGP03.phx.gbl... > Before creating an index on a table column, how to check if that column > was already indexed (with a different index name)? > > I have to do this in SQL Script. > > Thanks, > Sarah Hari Prasad wrote:
> Just run SP_HELP or SP_Helpindex on that table and see. if the specific Thanks for the reply but I have to do the checking through SQL Script > column is already indexed that creates indexes. Not by verifying it manually. That is still possible with the use of the system views that expose the
index columns. However, in that case it would probably be easier to have consistent index naming, and simply check for the existance of the named index. Gert-Jan Sarah Bram wrote: Show quoteHide quote > > Hari Prasad wrote: > > Just run SP_HELP or SP_Helpindex on that table and see. if the specific > > column is already indexed > > Thanks for the reply but I have to do the checking through SQL Script > that creates indexes. Not by verifying it manually. Gert-Jan Strik wrote:
> That is still possible with the use of the system views that expose the Can I see an example?> index columns. > However, in that case it would probably be easier to have consistent I sure do that for what I do now,> index naming, and simply check for the existance of the named index. but it's a 10 year old product with several hundred clients with no consistent naming. Thanks, Sarah If you are running SQL Server 2005, then have a look at the virtual
views sys.sysindexes and sys.sysindexkeys If you are on an earlier version, check out the tables sysindexes and sysindexkeys. I am sure you should be able to google some examples... Gert-Jan Sarah Bram wrote: Show quoteHide quote > > Gert-Jan Strik wrote: > > That is still possible with the use of the system views that expose the > > index columns. > > Can I see an example? > > > However, in that case it would probably be easier to have consistent > > index naming, and simply check for the existance of the named index. > > I sure do that for what I do now, > but it's a 10 year old product with several hundred clients with no > consistent naming. > > Thanks, > Sarah
Other interesting topics
Changing the text of the code of multiple stored procedure
moving a database causes it to be read-only Clus. Index keys How to configure SQLExpress on a workgroup SQL Server Backup Can not change index INCLUDE fields order.... SA Password help DATABASE Mail Account Setup Error Default Schema on SQL Server 2005 with Server Role "sysadmin" Conversion failed when converting datetime from character string |
|||||||||||||||||||||||