Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pnpsql
Posting Yak Master
246 Posts |
Posted - 2011-12-12 : 02:29:15
|
| I need to add 10 columns in a table, but i don't know if any column i need to add already exist in table.when i add all ten in one alter statement , and a column that already exists found then rest 9 not get add.pls help me..i don't want to use 10 alter statements.challenge everything |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-12-12 : 04:55:01
|
| If any of the columns exists all will not be added. Only way is to write seperate alter table statement to add columnsMadhivananFailing to plan is Planning to fail |
 |
|
|
sunnyleoneo
Starting Member
19 Posts |
Posted - 2011-12-12 : 06:15:23
|
| You can check whether column name exist in you table or not by following codeif Exists(select * from sys.columns where Name = N'columnName' and Object_ID = Object_ID(N'tableName'))begin -- Column Existsend |
 |
|
|
|
|
|