Sql 把Xml字符串轉換成一張表

分享一個Sql技巧,把xml字符串轉換成一個表格spa

1 1 DECLARE @IdHandel INT 
2 2 EXEC sp_xml_preparedocument @IdHandel OUTPUT, @Bar_Ip 
3 3 
4 4 INSERT INTO T_Bar_Ip_Info(Bar_id,Ip_from,Ip_to,IpFromStr,IpToStr,IsHead,AuditStatus,AuditTime,CreateTime)
5 5 SELECT @barId,Ip_from,Ip_To,IpFromStr,IpToStr,1,0,NULL,@Time FROM OPENXML(@IdHandel,'/ArrayOfBarIpModel/BarIpModel',2) WITH(Ip_from BIGINT,Ip_To BIGINT,IpFromStr VARCHAR(50),IpToStr VARCHAR(50)) 
6 6 
7 7 EXEC sp_xml_removedocument @IdHandel
相關文章
相關標籤/搜索