with temp as
(
select Id, UserId, OfficeID, RoleId, DeptId, IsDelete, IsEnd, ParentId
from [dbo].[DiGui_Demo]
where UserId =1 or OfficeID = 56 or DeptId = 77
union all
select a.Id, a.UserId, a.OfficeID, a.RoleId, a.DeptId, a.IsDelete, a.IsEnd, a. ParentId
from [DiGui_Demo] a
inner join temp on a.[parentid] = temp.[Id]
)
select distinct * from temp where IsEnd = 1
===================================================== create proc proc_DeleteDict
(
@autoId int
)
as
begin
with TEC as
(
select * from OA_Dict where AutoId = @autoId
union all
select a.* from OA_Dict a inner join TEC b on a.ParentId = b.AutoId
)
update OA_Dict set IsDelete = 1 where AutoId in
(
select autoid from TEC
)
end |
相关文章
- Java 类型, Hibernate 映射类型及 SQL 类型之间的相应关系
- 用SQL server导出到oracle,查询时提示“表或视图不存在ORA-00942”错误
- SQL 语句优化—— (一) 操作符优化
- pl sql练习(1)
- 面试问题 - SQL 中存储过程与函数的区别
- General Ledger Useful SQL Scripts
- CMD递归文件夹
- Mysql5.7自定义函数递归报错1424 Recursive stored functions and triggers are not allowed
- (转) java 通过 jdbc 链接 ms sql server 中出现 "no suitable driver for ..."
- java Mybatis框架动态SQL