Adding a new column between existing columns..

  • Hello Everyone,

    How can I add a new column (EMP_MID_NAME) between two existing columns (EMP_FIRST_NAME) and (EMP_LAST_NAME)?

    Regards

  • In Management Studio, right-click on the table, select "Modify", and insert the column. In T-SQL, you'll have to recreate the table and reload the data because ALTER TABLE ADD COLUMN only adds a column at the end.

    Greg

  • Yep.... Greg Charles is True

  • Thank you Greg, I'm using SQL 2005 and upon right clicking on my table I don't see a Modify option, however I used Design option and I'm able to insert new columns at desired places.

    Thanks again.

    Zulf

  • zulfansari (6/27/2008)


    Thank you Greg, I'm using SQL 2005 and upon right clicking on my table I don't see a Modify option, however I used Design option and I'm able to insert new columns at desired places.

    Thanks again.

    Zulf

    Behind the scenes the "old" table is dropped entirely and recreated with "position" where you asked it. It really does not matter the logical number where it "shows" in the UI. ALTER TABLE ADD COLUMN is a lot less invasive.


    * Noel

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

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