Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Sql Server Programming

ALTER TABLE doc_exa ADD @variable?

Sql Svr 2000.  Can I add a column to a table that is the contents of a

create table doc_exa (id INT)
declare @emp_cd varchar(10)
declare testCursor CURSOR for
select top 8 emp_cd from emp where termdate is null and home_store_cd='08'
open testCursor
fetch next from testCursor into @emp_cd
while @@fetch_status=0
alter table doc_exa add @emp_cd

expected result
id INT
slsp1 varchar(10)
slsp4 varchar(10)
slsp88 varchar(10)
slsp89 varchar(10)
slsp234 varchar(10)
slsp651 varchar(10)
slsp794 varchar(10)
slsp846 varchar(10)

Seems like a strange requirement to me. However, that ALTER could be done as dynamic SQL. Put the
ALTER TABLE in a variable then to EXEC(@sql).

Tibor Karaszi, SQL Server MVP

"Peter" <P@discussions.microsoft.com> wrote in message


Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc