Click here to Skip to main content
15,936,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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)
--declare @S varchar(20) 

declare @sql varchar(max)
 while len(@S) > 0
 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+','), '')

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
Updated 13-Mar-14 8:13am
GDdixit 14-Mar-14 3:42am    
can any one give suggetion ?

1 solution

Share this answer
GDdixit 14-Mar-14 3:31am    
no i am unable to under stand this ...
can u give any other example or solution..
GDdixit 14-Mar-14 5:32am    
Thank You so much bro
Maciej Los 14-Mar-14 12:11pm    
You're welcome ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900