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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 insert multiple records

Author  Topic 

semmert
Starting Member

1 Post

Posted - 2011-09-23 : 10:15:02
I am attempting to write a query to insert records into a database.

I have two variables, field1 and field2. Each field has one or more comma-delmited values.

I am trying to create a record for each combination of the values.

Example1

field1 = 123
field2 = abc

field1 field2
123 abc


Example2

field1 = 123,234,345
field2 = abc,bcd

field1 field2
123 abc
123 bcd
234 abc
234 bcd
345 abc
345 bcd

Any thoughts? I really appreciate any help.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-23 : 10:22:29
see scenario 4
http://visakhm.blogspot.com/search/label/cross%20apply

see parse values here
http://visakhm.blogspot.com/2010/02/parsing-delimited-string.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -