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.
| Author |
Topic |
|
lwhalen618
Starting Member
4 Posts |
Posted - 2008-05-14 : 23:27:56
|
| How do you insert a row when you have multiple values from a multiselect listbox? I have two tables, TableParent (ASSIGNNUM (PK), DESC, STARTDATE)TableChild (ASSIGNNUM (FK), EMPLOYEENUM)Each assignment (ASSIGNNUM) could have multiple employees (EMPLOYEENUM)connected with it. The user is choosing the employees from a multiselect listbox. I assume that I need to somehow loop through the multiple values to create the INSERT statement but don't know how to do that. Sample data:TableParent1....First Assignment....05/01/20082....Second Assignment...05/03/20083....Third Assignment....05/07/2008TableChild1....553422....334562....523433....352253....451213....11553Any suggestions would be appreciated! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-14 : 23:54:43
|
| [code]INSERT INTO TableChildSELECT t.ASSIGNNUM,FROM TableParent tCROSS APPLY dbo.fnParseList(',', @EmpList)[/code]Where @EmpList is parameter which contains comma seperated value passed from multiselect.The function dbo.fnParseList parses the comma seperated value and returns a table of empids. Serach for this function within this forum and create it in your db first before using this. |
 |
|
|
|
|
|