SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

arkiboys
Flowing Fount of Yak Knowledge

1422 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.

khtan
In (Som, Ni, Yak)

Singapore
17682 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.




KH
Time is always against us

Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22777 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

Madhivanan

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

nr
SQLTeam MVY

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?
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
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000