Monday, February 13, 2012

Adding Column Using TSQL With Sequence Specified

I am looking for ways to add new column to a table with records inside. If I add the column using this statement:
ALTER TABLE Table1 ADD NewColumn1 decimal(18, 2) NULL
The column would appear at the end.

Is there a way to set where the column should be placed? (Excluding dropping all columns and add the columns in sequence again). I know this might not be very important, I am interested in knowing how Enterprise Manager done this, since you can move a column up and down to change their sequence eventhough there're records inside.EM creates a temp table, then reorganizes the columns in the base table, then inserts the records into the newly structured table.

No comments:

Post a Comment