Solved

Adding multiple columns to a table

Posted on 2006-06-15
5
8,364 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

623 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