hello 2 all ...
i have a table in which there are three columns
id ProductId SubProductId
1 2 1
2 2 2
3 2 3
4 2 4
5 2 5
i want to write an procedure for inserting values in table given above
here SubProductId values come from check box list (multiple selectd items).
and i want to use only one variable for inserting check box list items in table ..
i googled internet and i find a procedure for this and customize it according to me ...
but there is one problem which i unable to solve
my procedure is .....
alter procedure sp_checkboxTest
(
@S varchar(20)
)
as
begin
SET NOCOUNT ON;
declare @sql varchar(max)
while len(@S) > 0
begin
print left(@S, charindex(',', @S+',')-1)
set @sql='insert into tblrmp values(''abc'','+left(@S, charindex(',', @S+',')-1)+')' exec(@sql)
set @S = stuff(@S, 1, charindex(',', @S+','), '')
end
end
on executing .... exec sp_checkboxTest '70,80,90' this will give result like
id ProductId SubProductId
1 abc 70
2 abc 80
3 abc 90
but i want abc value come from by passing parameter in procedure also ...
how to solve out this ... pls pls pls rply