Sql 把Xml字符串转换成一张表
分享一个Sql技巧,把xml字符串转换成一个表格
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