传入xml,在树表中递归,再归组加入其他表
发布时间:2020-12-16 06:24:36 所属栏目:百科 来源:网络整理
导读:declare @uid intset @uid=1declare @doc xmlset @doc=N'idssid id="001001" /sid id="001001009" //ids'--找出指定类的所以子类,加入表中declare @p intexec sp_xml_preparedocument @p OUTPUT,@doc delete from t_dor_operatorStruct where uid=@uid;with
declare @uid int set @uid=1 declare @doc xml set @doc=N' <ids> <sid id="001001" /> <sid id="001001009" /> </ids>' --找出指定类的所以子类,加入表中 declare @p int exec sp_xml_preparedocument @p OUTPUT,@doc delete from t_dor_operatorStruct where uid=@uid ;with tmp (unitId) as ( select unitId from t_scs_schoolStructure where fartherId in(SELECT id FROM OPENXML (@p,'/ids/sid',1) WITH (id varchar(50))) union all select t_scs_schoolStructure.unitId from t_scs_schoolStructure inner join tmp on tmp.unitId=t_scs_schoolStructure.fartherId ) insert into t_dor_operatorStruct(uid,sid) select @uid,unitId from tmp group by unitid exec sp_xml_removedocument @p (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |