converting a column from int to char

  • Hello cyber friends,

    After reviewing the specs for a new project and creating approx. 18 tables, and adding data into it, the developer wants to change an int column to char.  The problem is that the field is a primary key on the initial table and a foreign key on other numerous tables. 

    What is the best approach to fulfil this request.

    Thanking you in advance, Annie G.

  • 1. Drop all foreign keys and constraints on the affected columns. 

    2. Run ALTER TABLE <tableName> ALTER COLUMN <columnName> [char].... commands for each table/column to change.

    3. Re-create all constraints.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

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

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