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
 General SQL Server Forums
 New to SQL Server Programming
 Problem with adding a new column

Author  Topic 

newman
Starting Member

7 Posts

Posted - 2005-08-27 : 09:26:40
hello friends!

I hav a table..which has 4 columns and 5 rows..

whenever i add a new column it goes to end of the table..

Now i want to add a new column in between 2nd and 3rd column..

Is there a way to add a new column to a specified place in a table??

THANKYOU!

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-08-27 : 09:35:01
Not without dropping and recreating the table. SQL does not care where columns are positioned, you can always write a SELECT statement that arranges the columns in the sequence you prefer. And since that is the case, you can simply add the new column using ALTER TABLE myTable ADD newcolumn...etc., Books Online has the syntax under "ALTER TABLE".
Go to Top of Page

jaffa_cree
Starting Member

13 Posts

Posted - 2005-08-27 : 23:03:41
I think you can do this through Enterprise Manager.
Open the table in design view. Select the column you want to add in front of, and right click -> insert new column.

Not sure whether this can be done in QA though.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-08-28 : 08:50:33
All Enterpise Manager does is create a new table, copy the data to it, then drops the old and renames the new one. You can see this by saving the SQL that EM generates.
Go to Top of Page

svicky9
Posting Yak Master

232 Posts

Posted - 2005-08-28 : 16:13:42
Hi
Try this

Go to enterprise manager
right click the table
Open the design view
Highlight the column where u want another col to be inserted
Right click that and u have an option of inserting a new col

Vic


Vicky
Go to Top of Page
   

- Advertisement -