Sql – How to change column order in a table using sql query in sql server 2005

sqlsql-server-2005

How to change column order in a table using SQL query in SQL Server 2005?

I want to rearrange column order in a table using SQL query.

Best Answer

You cannot. The column order is just a "cosmetic" thing we humans care about - to SQL Server, it's almost always absolutely irrelevant.

What SQL Server Management Studio does in the background when you change column order there is recreating the table from scratch with a new CREATE TABLE command, copying over the data from the old table, and then dropping it.

There is no SQL command to define the column ordering.