ALTER TABLE IN CASCADE

  • Hi,

    I need to alter a column in a database table from varchar(5) to varchar(11). However, the tables involved are having primary key-foreign key contraints. How do I alter the columns. There is one obvious solution to disable all constraints and then alter the column. But are any ALTER TABLE CASCADE options available in SQL Server 2005 so that the child columns automatically get altered when the parent field is alterd. Please also let me know the syntax if possible.

  • If the column you're altering is the one that the constraints are on, then you'll have to drop the constraints, make the changes, then recreate the constraints.

    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
  • I think I acn also do the same by disabling the constraints. But I wanted to know are there any ALTER TABLE_NAME COLUMN_NAME DATATYPE CASCADE options?

  • No there aren't. You will have to disable the foreign and primary key constraints to modify the column.

    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
  • Thanx

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

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