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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Alter table

Author  Topic 

avijit_mca
Posting Yak Master

109 Posts

Posted - 2009-01-05 : 07:48:56
create table junk (id varchar(20),name varchar(50))

ALTER TABLE junk
ADD cola nvarchar(299) NULL

Is it possible to create column with variable.

My aim :
declare @i as int
declare @x as varchar(3)
set @x='aa'+@i
set @i=1
while @i<=10
begin

ALTER TABLE junk
ADD @x nvarchar(299) NULL -- Error
end

Actually i want to create column run time. bcoz no of column are not fixed .. its depend on no of days in months.
so if no of months is 30 then i need 30 + 2 (fixed column)column.

if u have any good idea pls share with me.
Regards,
Avijit


Regards,
avijit

Regards,
avijit

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-01-05 : 08:04:57
duplicate.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=117175
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-01-06 : 04:56:32
Don't post Duplicate...Entries
Go to Top of Page
   

- Advertisement -