Solved

Adding multiple columns to a table

Posted on 2006-06-15
5
8,362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Scott Pletcher
Scott Pletcher 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

740 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