34,588
社区成员
发帖
与我相关
我的任务
分享
set nocount on
go
create table #a00_Module(a00code int,a00name varchar(10))
insert #a00_Module select 1001, '系统管理'
insert #a00_Module select 1002 , '基础信息'
insert #a00_Module select 2001 , '订单管理'
insert #a00_Module select 2002 , '采购管理'
insert #a00_Module select 2003 , '配货管理'
insert #a00_Module select 2004 , '报表管理'
create table #a01_funinfo(a00code int,a01code int,a01name varchar(10))
insert #a01_funinfo select 1001, 1 ,'初始设置'
insert #a01_funinfo select 1001 , 2 , '权限管理'
insert #a01_funinfo select 1002 , 3 , '商品类别'
insert #a01_funinfo select 1002 , 4 , '扩展规格'
insert #a01_funinfo select 1002 , 5 , '商品品牌'
insert #a01_funinfo select 1002 , 6 , '商品信息'
insert #a01_funinfo select 1002 , 7 , '商户信息'
insert #a01_funinfo select 1002 , 8 , '客户信息'
insert #a01_funinfo select 1002 ,9, '数据词典'
go
select code = case a01code when 0 then a00code else a01code end
,a00name
from (
select a00code, a01code=0, a00name from #a00_Module
union
select a00code, a01code, a01name from #a01_funinfo
) as a
order by a00code, a01code
drop table #a01_funinfo, #a00_Module
-- code a00name
-- 1001 系统管理
-- 1 初始设置
-- 2 权限管理
-- 1002 基础信息
-- 3 商品类别
-- 4 扩展规格
-- 5 商品品牌
-- 6 商品信息
-- 7 商户信息
-- 8 客户信息
-- 9 数据词典
-- 2001 订单管理
-- 2002 采购管理
-- 2003 配货管理
-- 2004 报表管理
--
create table #a00_Module(a00code int,a00name varchar(10))
insert #a00_Module select 1001, '系统管理'
insert #a00_Module select 1002 , '基础信息'
insert #a00_Module select 2001 , '订单管理'
insert #a00_Module select 2002 , '采购管理'
insert #a00_Module select 2003 , '配货管理'
insert #a00_Module select 2004 , '报表管理'
create table #a01_funinfo(a00code int,a01code int,a01name varchar(10))
insert #a01_funinfo select 1001, 1 ,'初始设置'
insert #a01_funinfo select 1001 , 2 , '权限管理'
insert #a01_funinfo select 1002 , 3 , '商品类别'
insert #a01_funinfo select 1002 , 4 , '扩展规格'
insert #a01_funinfo select 1002 , 5 , '商品品牌'
insert #a01_funinfo select 1002 , 6 , '商品信息'
insert #a01_funinfo select 1002 , 7 , '商户信息'
insert #a01_funinfo select 1002 , 8 , '客户信息'
insert #a01_funinfo select 1002 ,9, '数据词典'
go
select a01code,a01name from(
select 1 px, a00code,a01code,a01name from #a01_funinfo
union
select 0 px,a00code,a00code,a00name from #a00_module)a
order by a00code,px,a01code
/*
a01code a01name
----------- ----------
1001 系统管理
1 初始设置
2 权限管理
1002 基础信息
3 商品类别
4 扩展规格
5 商品品牌
6 商品信息
7 商户信息
8 客户信息
9 数据词典
2001 订单管理
2002 采购管理
2003 配货管理
2004 报表管理
*/
go
drop table #a00_Module,#a01_funinfo
select code = case a01code when 0 then a00code else a01code end
,a00name
from (
select a00code, a01code=0, a00name from a00_Module
union
select a00code, a01code, a00name from a00_Module
) as a
order by a00code, a01code