Solved

Adding multiple columns to a table

Posted on 2006-06-15
5
8,358 Views
Last Modified: 2008-03-03
is there a way to add multiple columns to a table with one alter statement? does Sql Server even support such?
0
Comment
Question by:crishna1
5 Comments
 
LVL 5

Accepted Solution

by:
bwdowhan earned 400 total points
ID: 16913358
Yes you can,

Alter table my_table add
   [field1] [int] NULL,
   [field2] [varchar(30)] NULL,
   [field3} [int] NULL
0
 
LVL 5

Expert Comment

by:bwdowhan
ID: 16913368
oops... the last line should be [field3] [int] NULL

I mistype the closing square bracket as a closing curly bracket.
0
 
LVL 20

Assisted Solution

by:Sirees
Sirees earned 50 total points
ID: 16913395
Yes

alter  table tablename
add  Col1 varchar(10) ,  
     Col2 varchar(10)
0
 

Author Comment

by:crishna1
ID: 16913794
is this a new feature in 2005 or has it been there always? i thought Sql Server did'nt allow that earlier, i might be wrong.
0
 
LVL 69

Assisted Solution

by:ScottPletcher
ScottPletcher earned 50 total points
ID: 16914830
That has been there for quite a while.  You can *add* several columns at once, but you can only *alter* one column at a time; perhaps that is what you were thinking of.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now