I am needing to insert some database associations (Many-to-Many table in MS-SQL Server 2008) based off of a Person, and a Language. My incoming data includes a table full of people, a table full of languages, and people have a field of comma delimited languages that represent each language they are associated with.
So here's what the tables would look like
People
-----------------------------------------------
ID | First Name | Last Name | Languages
-----------------------------------------------
1 | Paul | Johnson | English,Spanish
2 | Jack | Johnson | English,Hindi
3 | Mark | Johnson | NULL
-----------------------------------------------
Language
--------------
ID | Name
--------------
1 | English
2 | Spanish
3 | Hindi
--------------
And I need to get it into a table, which would, at the completion, look like this:
PeopleLanguage
----------------------
PeopleID | LanguageID
----------------------
1 | 1
1 | 2
2 | 1
2 | 3
Now, I'd like to avoid using cursors or while loops to iterate over each physician, and perform the operation, but I can't think of a way outside of that to accomplish (also, I don't fully understand cursors :p)
Hopefully SO will be able to come up with a good solution for me.
Thanks!