Adding multiple columns to a table

is there a way to add multiple columns to a table with one alter statement? does Sql Server even support such?
crishna1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
bwdowhanConnect With a Mentor Commented:
Yes you can,

Alter table my_table add
   [field1] [int] NULL,
   [field2] [varchar(30)] NULL,
   [field3} [int] NULL
0
 
bwdowhanCommented:
oops... the last line should be [field3] [int] NULL

I mistype the closing square bracket as a closing curly bracket.
0
 
SireesConnect With a Mentor Commented:
Yes

alter  table tablename
add  Col1 varchar(10) ,  
     Col2 varchar(10)
0
 
crishna1Author Commented:
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
 
Scott PletcherConnect With a Mentor Senior DBACommented:
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
All Courses

From novice to tech pro — start learning today.