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)
 create column dynamically

Author  Topic 

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-05-29 : 11:33:33
How can i create column dynamically and access parameter for this col name?

@col nvarchar(100)
AS
ALTER TABLE Summary
ADD @col nvarchar(100);

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-29 : 12:32:23
Use dynamic sql
DECLARE @Sql varchar(2000)
SET @Sql='ALTER TABLE Summary ADD '+ @Col
EXEC(@Sql)

but question why you want to do this.
Go to Top of Page
   

- Advertisement -