传入xml,在树表中递归,再归组加入其他表

来源:互联网 发布:app软件推广 编辑:程序博客网 时间:2024/06/09 16:59
declare @uid intset @uid=1declare @doc xmlset @doc=N'<ids><sid id="001001" /><sid id="001001009" /></ids>'--找出指定类的所以子类,加入表中declare @p intexec 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 allselect 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 unitidexec sp_xml_removedocument @p

0 0
原创粉丝点击