文件名称:删除父节点下的子节点 存储过程版 新手需多看几遍
文件大小:902B
文件格式:TXT
更新时间:2016-08-18 06:45:49
存储过程 子父节点
删除父节点下的子节点 存储过程版 新手需多看几遍 create function dbo.aa(@i int) returns @t table(ml_id int,parent_id int,level int) as begin declare @level int set @level=0 insert into @t select ml_id,parent_id,@level from dbo.T_TEMP_MuLu where dbo.T_TEMP_MuLu.ml_id=@i while @@rowcount> 0 begin set @level=@level+1 insert into @t select a.ml_id,a.parent_id,@level from dbo.T_TEMP_MuLu a left join @t b on a.parent_id=b.ml_id where b.level=@level-1 end return end delete dbo.T_TEMP_MuLu where ml_id in (select ml_id from dbo.aa(49)) drop function aa truncate table dbo.T_TEMP_MuLu insert into dbo.T_TEMP_MuLu SELECT [ML_ID] ,[Parent_ID] ,[FolderFlag] ,[ML_Name] ,[BaoShi] ,[Dept] ,[ZiLiaoHe] ,[BZ] FROM [DB_TOPPING].[dbo].[T_YingJian]