Inserting multiple values | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Inserting multiple values

I am having an issue with populating a table. I have to populate a table called ‘tstudentsubjects’. This table has 2 fields, studentId and Electives. I have data for studentId which is unique and more than one Electives can be passed for Electives. (Both are composite keys) Note : The data for Electives is passed through an XML. I then parse it using xp_xmlpreparedocument and the Electives is availabe in a temp table. Now say I have the following values ready, StudentID : 100001
Electives : History
Science
Political Studies
What logic should I use to populate the table ‘tstudentsubjects’ Thanks, StarWarsBigBang
Something like INSERT INTO tstudentsubjects(StudentID, Elective)
SELECT StudentID, Elective
FROM OPENXML…. Roji. P. Thomas
SQL Server MVP
http://toponewithties.blogspot.com

]]>