• mukeshkane (9/10/2010)


    Is I am still missing something??

    Yes.

    The line

    ALTER TABLE MyTable DROP CONSTRAINT PK_MyIdGO

    should read

    ALTER TABLE MyTable DROP CONSTRAINT PK_MyId

    (That is, remove the GO at the end).

    When I wrote that you were missing a GO, I had not seen that the GO was there, but in the wrong place. You added the GO, but kept the extraneous one at the end of the line. Those two extra letters invalidated the DROP CONSTRAINT (because there is no constraint named PK_MyIDGO; the proper constraint name is PK_MyID).


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/