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 table to add columns in specific location

Author  Topic 

purplebadger
Starting Member

1 Post

Posted - 2006-07-13 : 06:12:20
Hi,

Is it possible to add columns to a table in a specific location using T-SQL?

I've done this using EM, but now I need to write a script to do it in the production environment. Simply appending the columns will cause a whole world of pain elsewhere and violate our table structure format (timestamp row must be last).

EM manager obviously has some way of doing it - is it something terrible like moving all the data to a temporary table, dropping and re-creating the table and then importing it all back?

Cheers,

nr
SQLTeam MVY

12543 Posts

Posted - 2006-07-13 : 07:01:11
Have a look at the script the em produces. You will probably find that it crates a new table and copies the data.

==========================================
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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-13 : 10:03:31
Also, ordinal position of a column doesnt matter if you use them in proper postions when selecting columns

Madhivanan

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

- Advertisement -