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
 SQL Server Administration (2000)
 how to add a column to the middle, not the bottom (or end), of a table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-26 : 09:09:24
David writes "Here's a hard question you don't seem to have covered already:

In SQL7 or SQL2k Enterprise Manager, in Design Table view, it is very easy to add a new column anywhere in the table.

But, using the ALTER TABLE command, I can only add a column to the very bottom (or end) of a table.

It seems like there must be a way to either add a column in the position I want, or re-arrange the columns whenever I want, but I can't find any way to do it (except creating a temporary table, copying the data into it, then renaming it).

Of course, re-arranging the columns serves no real purpose, other than keeping things neat and tidy, but I'm a computer geek, so neat-and-tidy is very important to me :-)

Thanks for a great website.
-David"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-03-26 : 09:19:09
quote:
It seems like there must be a way to either add a column in the position I want, or re-arrange the columns whenever I want, but I can't find any way to do it (except creating a temporary table, copying the data into it, then renaming it).


Nope, that's really the only way to do it:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=13910

I'll be honest, I've never considered this as an issue. If I had to add columns afterwards, they went to the end, no big deal. If I need them in a certain order, I modify the SELECT statements and views accordingly.

Go to Top of Page
   

- Advertisement -