SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Add new columns in between of existing columns
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

goodman2253
Yak Posting Veteran

83 Posts

Posted - 07/10/2012 :  08:21:27  Show Profile  Reply with Quote
Is it possible to add new columns in between of existing columns

There exist a table named total_code.
which contains the columns as in sequence
A B C D E

I want to add new column A1 and want that it should come and add like
A A1 B C D E

Thanks.

webfred
Flowing Fount of Yak Knowledge

Germany
8513 Posts

Posted - 07/10/2012 :  08:24:36  Show Profile  Visit webfred's Homepage  Reply with Quote
The sequence of columns in a table isn't important because you can change the order in the column list of your select statement.
The only way to get what you want - if you really want it - is to recreate the complete table.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Transact Charlie
Flowing Fount of Yak Knowledge

United Kingdom
3425 Posts

Posted - 07/10/2012 :  08:30:53  Show Profile  Visit Transact Charlie's Homepage  Reply with Quote
it's one of the tenants of a relational design. intrinsic order of rows or columns should never be important.

Of course when the engine lets you issue statements like:

INSERT tbFoo
SELECT a, b, c, d

Rather than

INSERT tbFoo ([colA], [colC], [colD], [colb])
SELECT a, b, c, d

Then it's easy for a lazy / ignorant coder to save up problems for the future.

Transact Charlie

Msg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
Go to Top of Page

Transact Charlie
Flowing Fount of Yak Knowledge

United Kingdom
3425 Posts

Posted - 07/10/2012 :  08:31:40  Show Profile  Visit Transact Charlie's Homepage  Reply with Quote
and obviously.... avoid
SELECT *
in any prod code.....

Transact Charlie

Msg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000