示例:
.net
DataSet ds=....
string xml = ds.GetXml();
xml = xml.Replace("'","''");
SQL :
DECLARE @idoc int; EXEC sp_xml_preparedocument @idoc OUTPUT,
N'<User>
<Dept>
<ItemID>1</ItemID>
<EmpID>123</EmpID>
<Type>0</Type>
</Dept>
<Dept>
<ItemID>2</ItemID>
<EmpID>123</EmpID>
<Type>1</Type>
</Dept>
</User>';
INSERT INTO A (ItemID,EmpID,Type)
SELECT ItemID,EmpID,Type FROM OPENXML (@idoc, '/User/Dept',2)
WITH (ItemID int,EmpID nvarchar(50),Type int);