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 |
steppinthrax
Starting Member
27 Posts |
Posted - 2009-09-29 : 16:33:23
|
This is what I'm trying to do.insert into tb_direc (direc_reci, direc_desc) values (@scope, select * from dbo.udf_split('dkd|dkdkd|fff','|'))dbo.udf_split is a function that splits a string by the specified delimeter. In this case it's a pipe (|). udf_split returns one table containing one column. I imagine I will need a cursor or something??? |
|
Zim327
Yak Posting Veteran
62 Posts |
Posted - 2009-09-29 : 16:50:00
|
how about putting this into a stored proc and thenjust use a while loop to iterate through the string? |
|
|
jeffw8713
Aged Yak Warrior
819 Posts |
Posted - 2009-09-29 : 16:51:35
|
INSERT INTO tb_direc (direc_reci, direc_desc)SELECT @scope ,* -- put the actual column returned from the udf here, much cleaner that way FROM dbo.udf_split('dkd|dkdkd|fff','|'));Not sure where @scope is coming from, or what the value should be - but that will insert into your table a row for each value in your delimited list with all rows having the same @scope value. |
|
|
steppinthrax
Starting Member
27 Posts |
Posted - 2009-09-30 : 11:25:50
|
How would you handle it if you are dealing with multiple tables in one insert such as this.INSERT INTO tb_ing (ing_reci, ing_amt, ing_unit) select @scope, Items from dbo.udf_split(@ing_desc,'|'), Items from dbo.udf_split(@ing_amt,'|'), Items from dbo.udf_split(@ing_unit,'|')FYI: All dbo.udf_split are returning the same number or rows. |
|
|
|
|
|
|
|