Can

  • When I try to drop the index using TSQL as follows:

    drop index TestIndex on Empdetails.Empid

    The error is:

    Msg 3701, Level 11, State 6, Line 1

    Cannot drop the index 'Empdetails.Empid.TestIndex', because it does not exist or you do not have permission.

    But I can do this from SSMS:

    What can be the reason? Any headsup!!

    -LK

  • Is the table called Empdetails? If it is then the syntax is drop indexTestIndex on Empdetails

    With the syntax you are using, SQL is looking for a table called EmpId in the schema Empdetails. You also get this error if you are in the wrong database

    You can get the correct syntax by going to management studio, right-clicking on the index and select Script Drop Index

  • Thanks DNA

  • You can also get the correct syntax by reading Books Online, the SQL help file. It really is very good.

    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
  • "...But I can do this from SSMS:..."

    Most SSMS functions can be scripted out to a query window without actually being run. Then you can see the syntax that SQL will generate and learn from it, modify it etc...

Viewing 5 posts - 1 through 4 (of 4 total)

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