Tuesday, 21 May 2013
     
AUSQLUG Forums Home   Search   Login   Register   Member List  
SQL Server 2005 Forums  > T-SQL Programming  > Adding a column to a table at a particular location  
 
Display using:  
Previous Thread :: Next Thread 
 Author Thread: Adding a column to a table at a particular location
JSBBS is not online. Last active: 23/08/2010 4:54:20 AM JSBBS
www.jsbbs.com.au
Top 50 Poster
Joined: 04 Mar 2005
Total Posts: 6
 
Adding a column to a table at a particular location
Posted: 13 Mar 2008 10:04 AM
Has anyone tried to add a column at a particular location without the old ...

1. create a temp table based on the original with the columns in the sequence you wish,
2. copy data across
3. delete original table
4. rename new table as original


I (vaguely) recall the ability to modify the column ordering via updates to the sys tables. Is this (still) possible (by either T-SQL or CLR programming)?

All help appreciated.
John
urid is not online. Last active: 12/04/2010 11:08:29 AM urid
Top 25 Poster
Joined: 18 Jun 2007
Total Posts: 34
 
Re: Adding a column to a table at a particular location
Posted: 13 Mar 2008 11:17 PM
Dear John

You cannot do that without re-creating a table. May I ask you, why it is important to you?
It is not recommended modifying system tables, do not do that.

Best Regards,
Uri Dimant
SQL Server MVP
http://dimantdatabasesolutions.blogspot.com/
JSBBS is not online. Last active: 23/08/2010 4:54:20 AM JSBBS
www.jsbbs.com.au
Top 50 Poster
Joined: 04 Mar 2005
Total Posts: 6
 
Re: Adding a column to a table at a particular location
Posted: 14 Mar 2008 12:34 PM
I've been asked to add columns at a particular location (ie, within the existing columns). I am personally against this but....



JSBBS is not online. Last active: 23/08/2010 4:54:20 AM JSBBS
www.jsbbs.com.au
Top 50 Poster
Joined: 04 Mar 2005
Total Posts: 6
 
Re: Adding a column to a table at a particular location
Posted: 31 Jul 2008 09:30 AM
Sorry about the long delay, but I finally managed to do this.

And thanks Uri. I did follow your recmomendation of creating a temporary table with the new definition, then copying data across, and then renaming it. Of course, contraints and FKs were troublesome.

Previous Thread :: Next Thread 
Page 1 of 1
 
AUSQLUG Forums  > SQL Server 2005 Forums  > T-SQL Programming  > Adding a column to a table at a particular location