SQL Query to add a new column after an existing column in SQL Server 2005

后端 未结 6 1150
后悔当初
后悔当初 2020-12-28 11:34

I need a SQL query which add a new column after an existing column, so the column will be added in a specific order.

Please suggest me if any ALTER quer

6条回答
  •  情歌与酒
    2020-12-28 12:07

    First add the new column to the old table through SSMStudio. Go to the database >> table >> columns. Right click on columns and choose new column. Follow the wizard. Then create the new table with the columns ordered as desired as follows:

    select * into my_new_table from (
    select old_col1, my_new_col, old_col2, old_col3
    from my_old_table 
    ) as A
    ;
    

    Then rename the tables as desired through SSMStudio. Go to the database >> table >> choose rename.

提交回复
热议问题