Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

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 the SQL query.

1 Answer

0 votes
by (40.7k points)

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.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...