日期:2014-05-17  浏览次数:20592 次

SQL cte问题
create trigger ShanChu_Delete 
  on ShanChu for delete
as
declare @id int
select @id=id from deleted
;with cte as
(
  select * from shanchu where type=@id
  union all
  select a.* from shanchu a join cte b on a.type=b.id
)
delete ShanChu where id in(select id from cte)
-------------------我需要在这里继续引用cte做更新操作
-------------------或者还有其他什么操作
-------------------请问有什么办法可以实现
go


------解决方案--------------------
引用楼主 fei329277920 的帖子:
create trigger ShanChu_Delete
on ShanChu for delete
as
declare @id int
select @id=id from deleted
;with cte as
(
select * from shanchu where type=@id
union all
select a.* from shanchu a join cte b on a.type=b.id
)
delete ShanChu where id in(select id from cte)
-------------------我需要在这里继续引用cte做更新操作
-------------------或者还有其他什么操作
--------…