One question I received quite often. How to change the order of the column in database table? It happens many times table with few columns is already created. After a while there is need to add new column to the previously existing table. Sometime it makes sense to add new column in middle of columns at specific places. There is no direct way to do this in SQL Server currently. Many users want to know if there is any workaround or solution to this situation.
First of all, If there is any application which depends on the order of column it is really not good programming and will create problem for sure in future. In ideal scenario there should be no need of order of column in database table. Any column can be any where and it can be used for any data process (INSERT, UPDATE, SELECT).
There are few cases where order of column matters. Let us see the valid and invalid cases of dependence on order of column.
If there is application of BULK INSERT or BCP the order of column matters when creating the table. This is valid reason for the case where order of column matters. If there is insert statement where column names are not specified the order of column will create issue, this case demonstrate lazy developer and inappropriate coding style.
If you really want to insert your column at any specific place. There are two different ways to do that.
Method 1 : Add column in Management Studio using GUI and visual aid and create the table with necessary order of column. If table is too large, this put lock on entire table and create temporary outage for that table to be used.
Method 2 : Create new table with the name “New_YourTable” name with your desired table structure and column order. Insert values from your existing “YourTable” to this “New_YourTable”. Drop the existing table “YourTable” and rename “New_YourTable” to “YourTable”. This is again resource consuming exercise along with chance of getting something wrong if this is heavily used production server.
Method 3 : Just do not worry, keep the column as they are but you can create view on the base table with your desired column order.
Reference : Pinal Dave (http://www.SQLAuthority.com)






Thanks for the post. I thought it was a good question. I personally like to have a rhythm and reason to the order of columns, especially when printing out a diagram of the database. I wish there was a better way of doing it instead of locking the table or creating a new table and deleting the old. Thanks for the posts.
When I add new column in Management Studio, my change times out after about one minute. How to prevent it?
wats the query for that ‘changing the order of columns in a table’
One shouldn’t really change the order too often
I remember when we had to swap Latitude & Longitude columns, it was a mess, so we just ended up renaming the column names.
It’s weird to see column1, Longitude, Latitude, column2 order though
SSMS sucks because it creates a TEMP table
copy everything from old table to TEMP
then rename TEMP table to your old table name
It ALWAYS times out if there is a lot of data
Do it in SQL Scripts