SqlServer里,一条sql进行递归删除
存储过程方法:
2 @did int
3 as
4 with my1 as(select * from News_Class where id = @did
5 union all select News_Class.* from my1, News_Class where my1.id = News_Class.ParentID
6 )
7 delete from News_Class where exists (select id from my1 where my1.id = News_Class.id)
8 go
9
10 exec up_delete_nclass 16
非存储过程方法:
2 union all select aaa.* from my1, aaa where my1.id = aaa.pid
3 )
4 delete from aaa where exists (select id from my1 where my1.id = aaa.id)
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。