)) ),sortNum int) as BEGIN DECLARE @sortNum int --得到当前id的父id, select @id = ParentId, @sortNum =Sortnum from Sys_Departments where keyId = @id and ParentId is not NULL BEGIN --循环输入插入 insert into @t_level select @id, @sortNum --------------------------…
-->Title:Generating test data -->Author:wufeng4552 -->Date :2009-09-30 08:52:38 set nocount on if object_id('tb','U')is not null drop table tb go create table tb(ID int, ParentID int) , , , , , , , -->Title:查找指定節點下的子結點 if object_id('Uf_GetChil…
1.无参数查询 var model = db.Database.SqlQuery<UserInfo>("select* from UserInfoes ").ToList(); 2.有参查询 var model = db.Database.SqlQuery<UserInfo>("select* from UserInfoes where id=@ID ",new SqlParameter("@ID",id)).ToLi…
T-Sql 递归查询(给定节点查所有父节点.所有子节点的方法) -- 查找所有父节点with tab as( select Type_Id,ParentId,Type_Name from Sys_ParamType_V2_0 where Type_Id=316--子节点 union all select b.Type_Id,b.ParentId,b.Type_Name from tab a,--子节点数据集 Sys_ParamType_V2_0 b --父节点数据集 where a.…
A very big corporation is developing its corporative network. In the beginning each of the N enterprises of thecorporation, numerated from 1 to N, organized its own computing and telecommunication center. Soon, foramelioration of the services, the co…
--查询ID = '009'的所有父节点 ' ;WITH T AS ( SELECT ID , PID , NAME FROM TB WHERE ID = @ID UNION ALL SELECT A.ID , A.PID , A.NAME FROM TB AS A JOIN T AS B ON A.ID = B.PID ) SELECT * FROM T ORDER BY ID /* ID PID NAME ---- ---- ---------- 001 NULL 广东省 003 001 深…
-- 查找所有父节点with tab as( select Type_Id,ParentId,Type_Name from Sys_ParamType_V2_0 where Type_Id=316--子节点 union all select b.Type_Id,b.ParentId,b.Type_Name from tab a,--子节点数据集 Sys_ParamType_V2_0 b --父节点数据集 where a.ParentId=b.Type_Id --子节点数据集.paren…