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 |
krugg
Starting Member
12 Posts |
Posted - 2006-10-16 : 19:39:07
|
Hi, Can't anyone tell me why this won't work? I've turned google upside down on this one. I need to dynamically add columns to a table inside a stored procedure.create table basicTable (ID INT IDENTITY)declare @colTwo char(10)set @colTwo = 'houseType'alter table basicTable ADD @colTwo int nullThanksKrugg |
|
krugg
Starting Member
12 Posts |
Posted - 2006-10-16 : 19:50:33
|
cancel that!set @sql = 'alter table basicTable ADD '+@colTwo+' int null'exec(@sql)that was easy! |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-16 : 21:09:50
|
Why do you want to add columns dynamically?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|