How to Disable an index in sql server 2000

  • Hi all,

    I am using SQL SERVER 200.I want to disable created indexes on a table

    i tried the following sql , it throwing error

    alter index FIRST_REF on tblComponentComponentJoin DISABLE

    can anybody help in this is highly appreciated

    Thanks

    shamsudheen

  • There's no way to disable an index in SQL 2000. You'll have to drop it.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks Gail Shaw

    i have another question related to this topic. i am having a view of joining two table with one key and each table have multiple indexes.my question is when i run the view is it will use the indexes or not

    thanks

  • Maybe. It depends on the queries run, the data distribution, the indexes you have. It's not a question that can be answered in general.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • First, having an index on a table won't slow down reads of that table assuming the reads use a different index. Second, get an execution plan for the query and then you'll know which indexes it uses or doesn't. Just a reminder, while an index scan is "using" the index, it isn't necessarily using it well.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • With Gail and Grant of course. It also depends on how you and where you are putting the [where] condition in your join. Like what Gail said, there is no general answer for this. You will have to run the query and see the execution plan and see it from there.

    [font="Verdana"]Imagination is more important than knowledge-Albert Einstein[/font]

  • SQL King (4/17/2008)


    With Gail and Grant of course. It also depends on how you and where you are putting the [where] condition in your join. Like what Gail said, there is no general answer for this. You will have to run the query and see the execution plan and see it from there.

    hi

    in my query i only join with keys no filter condition . i found it is still using index.Thanks Gai,Grant and Sql king for your effort

  • Check this whether it works or not:

    ALTER INDEX [IX_name] ON table DISABLE

    GO

    I don't have 2000 so I can't test it but found this solution in 2-3 sites.

    Hope it works.:)

    Also read these articles:

    http://blog.sqlauthority.com/2007/05/17/sql-server-disable-index-enable-index-alter-index/

    http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/tunesql.mspX

  • Anirban Paul (4/17/2008)


    Check this whether it works or not:

    ALTER INDEX [IX_name] ON table DISABLE

    GO

    Alter Index is only 2005 and higher. 2000 didn't have the command at all.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (4/18/2008)


    Anirban Paul (4/17/2008)


    Check this whether it works or not:

    ALTER INDEX [IX_name] ON table DISABLE

    GO

    Alter Index is only 2005 and higher. 2000 didn't have the command at all.

    As I told you I couldn't check as I found in under SQL Server 2000 in some sites. I never used it when I was using SQL Server 2000. I used to drop indexes. So when I saw in sites I thought let me put it in the forum to clear my doubts. Thanks Gail for your comment.

    :):)

  • Anirban Paul (4/18/2008)


    As I told you I couldn't check as I found in under SQL Server 2000 in some sites.

    No worries. I just wanted to clarify things

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (4/18/2008)


    Anirban Paul (4/17/2008)


    Check this whether it works or not:

    ALTER INDEX [IX_name] ON table DISABLE

    GO

    Alter Index is only 2005 and higher. 2000 didn't have the command at all.

    You are right, i also droping and recreating, it is working fine

    can i ask you one more question which i already posted , but i did not recieve solution

    following is my query

    SET @strSql = 'SELECT * FROM ' + @strViewName

    EXEC @rowcount = sp_executesql @strSql

    in @rowcount i am getting return value 0 . but i wand rows affected value

    can you help me.

    thanks in advance

  • What you're getting back from sp_executesql that way is the return value. Traditionally that's 0 if there was no error, otherwise it's the error code. But that depends on the implementation of sp_executesql

    Try

    SET @strSql = 'SELECT * FROM ' + @strViewName

    EXEC sp_executesql @strSql

    select @rowcount = @@rowcount

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply