我必须将多条记录插入到一个表中,同时将第一个表的标识列插入到另一个表中。我可以避免循环吗?
已编辑
i have two tables named StudentMaster and StudentSujects.
First Table structure is (StudentID int Identity(1,1),StudentName varchar(100))
Second table structure is (SubjectID int Identity(1,1),StudentID int,SubjectName varchar(100)).
“StudentSujects”表中的 StudentID 是第一个表“StudentMaster”的标识列。
INSERT INTO StudentMaster
(
StudentName
)
SELECT StudentName
FROM OPENXML(@hDoc,'/XML/Students')
WITH( StudentName varchar(100) 'StudentName')
I am inserting multiple records in to the first table using the above query.I the mean time i have to insert the identity column of each row in to the second table.