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

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 alter column

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-07-12 : 02:52:35
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.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-07-12 : 02:57:19
The order of the column is not important.

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




KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-07-12 : 04:39:31
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

Madhivanan

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

nr
SQLTeam MVY

12543 Posts

Posted - 2007-07-12 : 05:26:50
>> Is this possible in sql?
no

Have a look at
http://www.nigelrivett.net/SQLAdmin/PageStructure.html

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
   

- Advertisement -