存储过程 保存 xml 数据


示例:

.net

DataSet ds=....

string xml = ds.GetXml();
xml = xml.Replace("'","''");

SQL :

DECLARE @idoc int; EXEC sp_xml_preparedocument @idoc OUTPUT,
  N'<User>\r\n
 <Dept>\r\n   
  <ItemID>1</ItemID>\r\n  
  <EmpID>123</EmpID>\r\n   
  <Type>0</Type>\r\n
</Dept>\r\n
 <Dept>\r\n   
    <ItemID>2</ItemID>    \r\n    
    <EmpID>123</EmpID>\r\n   
    <Type>1</Type>\r\n  
 </Dept>\r\n
</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);

 

相关文章:

  • 2021-07-09
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-01
  • 2021-10-12
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2021-10-15
  • 2021-12-19
相关资源
相似解决方案