当前位置: 代码迷 >> ASP.NET >> SQL TREE解决方法
  详细解决方案

SQL TREE解决方法

热度:1888   发布时间:2013-02-25 00:00:00.0
SQL TREE
SQL code
CREATE TABLE [dbo].[tblAdminNavigation](    [NavID] [int] IDENTITY(1,1) NOT NULL,    [NavName] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,    [ParentID] [int] NULL,    [IsNav] [bit] NULL,    [NavUrl] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,    [Sort] [int] NULL,    [Remark] [nvarchar](200) COLLATE Chinese_PRC_CI_AS NULL,    [PermissionCode] [int] NULL,    [PermissionFile] [varchar](200) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [PK_tblAdminNavigation] PRIMARY KEY CLUSTERED (    [NavID] ASC)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]GOSET ANSI_PADDING OFFGOEXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'导航' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tblAdminNavigation', @level2type=N'COLUMN',@level2name=N'NavID'GOEXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'导航名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tblAdminNavigation', @level2type=N'COLUMN',@level2name=N'NavName'GOEXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'父节点ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tblAdminNavigation', @level2type=N'COLUMN',@level2name=N'ParentID'GOEXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否为导航' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tblAdminNavigation', @level2type=N'COLUMN',@level2name=N'IsNav'GOEXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'导航链接' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tblAdminNavigation', @level2type=N'COLUMN',@level2name=N'NavUrl'GOEXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'导航排序' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tblAdminNavigation', @level2type=N'COLUMN',@level2name=N'Sort'GOEXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tblAdminNavigation', @level2type=N'COLUMN',@level2name=N'Remark'GOEXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权限代码(取枚举类型)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tblAdminNavigation', @level2type=N'COLUMN',@level2name=N'PermissionCode'GOEXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'权限对应的文件路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tblAdminNavigation', @level2type=N'COLUMN',@level2name=N'PermissionFile'


测试数据如下
SQL code
SET IDENTITY_INSERT [dbo].[tblAdminNavigation] ONINSERT [dbo].[tblAdminNavigation] ([NavID], [NavName], [ParentID], [IsNav], [NavUrl], [Sort], [Remark], [PermissionCode], [PermissionFile]) VALUES (1, N'学员管理', 0, 1, N'', 1, N'', 0, N'')INSERT [dbo].[tblAdminNavigation] ([NavID], [NavName], [ParentID], [IsNav], [NavUrl], [Sort], [Remark], [PermissionCode], [PermissionFile]) VALUES (2, N'学员列表', 1, 1, N'../Student/List', 12, N'', 0, N'')INSERT [dbo].[tblAdminNavigation] ([NavID], [NavName], [ParentID], [IsNav], [NavUrl], [Sort], [Remark], [PermissionCode], [PermissionFile]) VALUES (3, N'教务管理', 0, 1, N'', 2, N'', 0, N'')INSERT [dbo].[tblAdminNavigation] ([NavID], [NavName], [ParentID], [IsNav], [NavUrl], [Sort], [Remark], [PermissionCode], [PermissionFile]) VALUES (4, N'班级列表', 3, 1, N'../Student/List', 2, N'', 0, N'')INSERT [dbo].[tblAdminNavigation] ([NavID], [NavName], [ParentID], [IsNav], [NavUrl], [Sort], [Remark], [PermissionCode], [PermissionFile]) VALUES (5, N'新增学员', 1, 1, N'../ServiceLog/List', 13, N'', 0, N'')INSERT [dbo].[tblAdminNavigation] ([NavID], [NavName], [ParentID], [IsNav], [NavUrl], [Sort], [Remark], [PermissionCode], [PermissionFile]) VALUES (6, N'新增班级', 3, 1, N'../Student/List', 1, N'', 0, N'')SET IDENTITY_INSERT [dbo].[tblAdminNavigation] OFF
  相关解决方案