I have a web page which has 20 checkboxes with numbers 1-20. I am trying to create a stored procedure which takes these parameters passed from the page (ck1, ck2,ck3, etc.) and stores into a table.
This doesn't work. I just am not thinking today. I want to create a dynamic variable and assign the value passed to that dynamic variable.
Any ideas
Code:
CREATE TABLE #temptest (
[intStep] [int] NOT NULL ,
[vchDisplayStep] [varchar] (19) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
DECLARE @intFlag INT,
@intStep varchar(20),
@vchDisplay varchar(25),
@tnyActive1 tinyint,
@tnyActive2 tinyint,
@vchActiveStepDisplay1 varchar(19),
@vchActiveStepDisplay2 varchar(19),
@sql varchar(500)
select @tnyActive1 = 10,
@tnyActive2 = 20,
@vchActiveStepDisplay1 = 'A',
@vchActiveStepDisplay2 ='B'
SET @intFlag = 1
WHILE (@intFlag <=2)
BEGIN
print @intFlag
print @intStep
Print @vchDisplay
select @sql = 'insert into #temptest (intStep,vchDisplayStep)
values(@tnyActive'+ Cast(@intFlag as varchar(5))+', @vchActiveStepDisplay'+ Cast(@intFlag as varchar(5))+ ')'
--print @sql
Exec( @sql)
SET @intFlag = @intFlag + 1
--IF @tnyActive+@intFlag = 0
--BREAK;
END
GO
This doesn't work. I just am not thinking today. I want to create a dynamic variable and assign the value passed to that dynamic variable.
Any ideas