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.
| Author |
Topic |
|
js.reddy
Yak Posting Veteran
80 Posts |
Posted - 2010-03-05 : 08:00:18
|
| HiI have a table called 'mytable' with three columns 'col1','col2','col3'.Now i want to add a new column named 'newcol' between col1 and col2.Is there any way to do this by t-sql query.Regards |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-05 : 08:03:01
|
| There is no simple way to do from sqlWhy do you need this?Column position is not important as long as you use column names in the required order in the SELECT statementMadhivananFailing to plan is Planning to fail |
 |
|
|
Bru
Starting Member
4 Posts |
Posted - 2010-03-05 : 08:51:36
|
| As Madhivanan indicated, there is no straight forward way of doing it. You have to create a new table with the structure you want (the new column in middle of the existing ones) and then move data and rename the old and new ones. This is what happens behind scenes when you do it from Management Studio.I would second his statement, the columns order in the table does not have any significance.Bru Medishettywww.LearnSQLWithBru.com |
 |
|
|
|
|
|