Syntax for Drop column and all other references/constraints associated with it

  • Hi, I am newbie to this community and SQLServer. I want to delete a column and all referential integrities associated with it (such as FK, indexes and statistics on it). ANy suggestions on the syntax or any pointers where i can read?

    Thanks in advance,

    N

  • First drop any constraints

    ALTER TABLE <Table Name> DROP CONSTRAINT <Constraint Name>

    Then drop the indexes

    DROP INDEX <Index Name> ON <Table Name>

    Then drop the column

    ALTER TABLE <Table Name> DROP COLUMN <Column Name>

    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 2 posts - 1 through 1 (of 1 total)

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