use test
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Upr]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Upr]
GO
CREATE TABLE [Upr]([ID] [int] NOT NULL ,[lvl] [int] NOT NULL ,[pos] [int] NOT NULL, [ParentID] [int] NOT NULL) ON [PRIMARY]
INSERT INTO Upr (ID, lvl, pos, ParentID) VALUES(11,0, 1, 0)
INSERT INTO Upr (ID, lvl, pos, ParentID) VALUES(12,1, 2, 0)
INSERT INTO Upr (ID, lvl, pos, ParentID) VALUES(13,1, 3, 0)
INSERT INTO Upr (ID, lvl, pos, ParentID) VALUES(14,1, 4, 0)
INSERT INTO Upr (ID, lvl, pos, ParentID) VALUES(15,2, 5, 0)
INSERT INTO Upr (ID, lvl, pos, ParentID) VALUES(16,0, 6, 0)
INSERT INTO Upr (ID, lvl, pos, ParentID) VALUES(17,1, 7, 0)
INSERT INTO Upr (ID, lvl, pos, ParentID) VALUES(18,2, 8, 0)
INSERT INTO Upr (ID, lvl, pos, ParentID) VALUES(19,2, 9, 0)
INSERT INTO Upr (ID, lvl, pos, ParentID) VALUES(20,3, 10,0)
|