Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 alter column
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Flowing Fount of Yak Knowledge

1433 Posts

Posted - 07/12/2007 :  02:52:35  Show Profile  Reply with Quote
How can I change the position of a column in a table using sql.
If I run the following, the column always gets added to the end.
alter table tbl1 add column column11

I would like to use sql to give the exact position i.e. after column 2 or before column 3...

Is this possible in sql?

p.s. Just interested to know if sql is capable of doing such query.

In (Som, Ni, Yak)

17689 Posts

Posted - 07/12/2007 :  02:57:19  Show Profile  Reply with Quote
The order of the column is not important.

When you retrieve the data you can define the ordering of column in your select statement.

Time is always against us

Go to Top of Page

Premature Yak Congratulator

22864 Posts

Posted - 07/12/2007 :  04:39:31  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Is there any specific reason you want the column at the particular ordinal position?
If you use front end application, there instead of Rs(0), Rs(1), etc, you should use Rs("colName1"),Rs("colName2"),etc. Then ordinal position doesnt matter


Failing to plan is Planning to fail
Go to Top of Page


United Kingdom
12543 Posts

Posted - 07/12/2007 :  05:26:50  Show Profile  Visit nr's Homepage  Reply with Quote
>> Is this possible in sql?

Have a look at

It'll give you an idea of what would be involved and why it's not available.
There is a sequence number for the columns in the table which could be used to reorder the client access but it shouldn't make any difference so isn't used.

Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000