以下为引用的内容:
-- create table script
CREATE TABLE dbo.UserAccess
(
UserID varchar ( 20 ) NOT NULL ,
Department varchar ( 50 ) NOT NULL
)
CREATE TABLE [ dbo ] . [ Orders ] (
[ OrderID ] [ int ] NOT NULL ,
[ CustomerName ] [ varchar ] ( 20 ) NOT NULL ,
[ OrderTotal ] [ money ] NOT NULL ,
[ Department ] [ varchar ] ( 50 ) NOT NULL
)
CREATE TABLE dbo.Departments
(
Department varchar ( 50 ) NOT NULL ,
ParentDepartment varchar ( 50 )
)
-- end create table script
-- script to clear then populate example tables
-- clear tables
Delete from departments
Delete from orders
Delete from useraccess
-- insert departments table
INSERT INTO [ dbo ] . [ Departments ] ( [ Department ] , [ ParentDepartment ] ) VALUES ( ' North America ' , '' )
INSERT INTO [ dbo ] . [ Departments ] ( [ Department ] , [ ParentDepartment ] ) VALUES ( ' East ' , ' North America ' )
INSERT INTO [ dbo ] . [ Departments ] ( [ Department ] , [ ParentDepartment ] ) VALUES ( ' Southeast ' , ' East ' )
INSERT INTO [ dbo ] . [ Departments ] ( [ Department ] , [ ParentDepartment ] ) VALUES ( ' Northeast ' , ' East ' )
INSERT INTO [ dbo ] . [ Departments ] ( [ Department ] , [ ParentDepartment ] ) VALUES ( ' West ' , ' North America ' )
INSERT INTO [ dbo ] . [ Departments ] ( [ Department ] , [ ParentDepartment ] ) VALUES ( ' Southwest ' , ' West ' )
INSERT INTO [ dbo ] . [ Departments ] ( [ Department ] , [ ParentDepartment ] ) VALUES ( ' Northwest ' , ' West ' )
-- insert orders table
INSERT INTO [ dbo ] . [ Orders ] ( [ OrderID ] , [ CustomerName ] , [ OrderTotal ] , [ Department ] ) VALUES ( 1 , ' Harris ' , ' 11.00 ' , ' East ' )
INSERT INTO [ dbo ] . [ Orders ] ( [ OrderID ] , [ CustomerName ] , [ OrderTotal ] , [ Department ] ) VALUES ( 2 , ' Corrigan ' , ' 22.00 ' , ' Southeast ' )
INSERT INTO [ dbo ] . [ Orders ] ( [ OrderID ] , [ CustomerName ] , [ OrderTotal ] , [ Department ] ) VALUES ( 2 , ' Corrigan ' , ' 22.00 ' , ' Southeast ' )
INSERT INTO [ dbo ] . [ Orders ] ( [ OrderID ] , [ CustomerName ] , [ OrderTotal ] , [ Department ] ) VALUES ( 3 , ' Baldwin ' , ' 33.00 ' , ' Southeast ' )
INSERT INTO [ dbo ] . [ Orders ] ( [ OrderID ] , [ CustomerName ] , [ OrderTotal ] , [ Department ] ) VALUES ( 4 , ' Pillow ' , ' 44.00 ' , ' Northeast ' )
INSERT INTO [ dbo ] . [ Orders ] ( [ OrderID ] , [ CustomerName ] , [ OrderTotal ] , [ Department ] ) VALUES ( 5 , ' Carpenter ' , ' 55.00 ' , ' Northeast ' )
INSERT INTO [ dbo ] . [ Orders ] ( [ OrderID ] , [ CustomerName ] , [ OrderTotal ] , [ Department ] ) VALUES ( 6 , ' Meyer ' , ' 66.00 ' , ' West ' )
INSERT INTO [ dbo ] . [ Orders ] ( [ OrderID ] , [ CustomerName ] , [ OrderTotal ] , [ Department ] ) VALUES ( 7 , ' Gonzalez ' , ' 77.00 ' , ' Southwest ' )
INSERT INTO [ dbo ] . [ Orders ] ( [ OrderID ] , [ CustomerName ] , [ OrderTotal ] , [ Department ] ) VALUES ( 8 , ' Hall ' , ' 88.00 ' , ' Northwest ' )
INSERT INTO [ dbo ] . [ Orders ] ( [ OrderID ] , [ CustomerName ] , [ OrderTotal ] , [ Department ] ) VALUES ( 9 , ' Patrick ' , ' 99.00 ' , ' Southwest ' )
-- insert user access table
INSERT INTO [ dbo ] . [ UserAccess ] ( [ UserID ] , [ Department ] ) VALUES ( ' BLambert ' , ' Southwest ' )
INSERT INTO [ dbo ] . [ UserAccess ] ( [ UserID ] , [ Department ] ) VALUES ( ' MDavis ' , ' East ' )
INSERT INTO [ dbo ] . [ UserAccess ] ( [ UserID ] , [ Department ] ) VALUES ( ' MDavis ' , ' Southeast ' )
INSERT INTO [ dbo ] . [ UserAccess ] ( [ UserID ] , [ Department ] ) VALUES ( ' MDavis ' , ' Northeast ' )
INSERT INTO [ dbo ] . [ UserAccess ] ( [ UserID ] , [ Department ] ) VALUES ( ' WSimmons ' , ' Northeast ' )
-- end script to clear then populate example tables
|