ALTER COLUMN (Primary Key) in SQL Server

  • What is the procedure to alter a column (increasing primary key column size ) of a table in SQL Server?

    I know that the constraint holding for a primary key should be deleted first, change the size of column and create constraint again for primary key. Also the constraint & field size should be modified for the dependent tables.

    What should we do if that column is dependent of 200 or more tables? Should we keep on doing this process manually?

    Any feasible solution to solve this!

    Note: Table is dependent on Views, Stored Procedures apart from other tables.

    Thanks in advance.

     

  • ALTER Table Drop Constraint, ALTER Table Change Column, ALTER Table Add Constraint, ALTER Procs, ALTER Views and you can fix the dependency with Management Studio.  A lot of details but not complicated.   Run a search for all of the above in the BOL(books online).   Hope this helps.

     

    Kind regards,
    Gift Peddie

  • Should i keep on altering 300 or more depending tables if the master table is dependent on 300 tables?

    I'm not dealing with less number of tables. So it should be complicated and especially time taking and if anything missed out in doing changes, its difficult to find what the change was.

    Regards

    Vis

  • I dont think so but you can see the dependencies in the database diagram in Management Studio so you know what to change, it is easier in 2005 than 2000.  Hope this helps.

     

    Kind regards,
    Gift Peddie

  • I found 90 dependent tables in Enterprise Manger. It is very difficult to do changes manually. Any other feasible solution????

    Thanks

    Vis

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

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