Create Demo Tables

AdSense

Create Demo Tables

Create demo tables.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'[tmpEmployee]') AND type IN (N'U')) 
BEGIN
DROP TABLE [tmpEmployee]
END

IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'[tmpDepartment]') AND type IN (N'U'))
BEGIN
DROP TABLE [tmpDepartment]
END

CREATE TABLE [tmpDepartment](
[departmentID] INT NOT NULL PRIMARY KEY,
[departmentName] VARCHAR(250) NOT NULL,
) ON [PRIMARY]

INSERT INTO [tmpDepartment] ([departmentID], [departmentName]) VALUES
(1, N'Engineering'),
(2, N'Administration'),
(3, N'Sales'),
(4, N'Marketing'),
(5, N'Finance')


CREATE TABLE [tmpEmployee](
[employeeID] INT NOT NULL PRIMARY KEY,
[firstName] VARCHAR(250) NOT NULL,
[lastName] VARCHAR(250) NOT NULL,
[departmentID] INT NOT NULL REFERENCES [tmpDepartment](departmentID),
[startDate] DATETIME NOT NULL,
[endDate] DATETIME NULL
) ON [PRIMARY]

INSERT INTO [tmpEmployee] ([employeeID], [firstName], [lastName], [departmentID], [startDate]) VALUES
(1, N'Orlando', N'Gee', 1, '2016-01-01 07:12:34.167'),
(2, N'Keith', N'Harris', 2, '2019-10-01 08:30:34.167'),
(3, N'Donna', N'Carreras', 3, '2021-06-07 07:12:34.167'),
(4, N'Janet', N'Gates', 3, '2021-03-01 07:12:34.167'),
(5, N'David', N'Golden', 3, '2017-12-25 08:12:34.167'),
(6, N'Mary', N'Green', 3, '2019-04-28 07:12:34.167'),
(7, N'Jenifer', N'Rodriguez', 1, '2017-12-25 08:12:34.167'),
(8, N'Harry', N'Brown', 1, '2021-01-25 07:30:34.167'),
(9, N'John', N'Miller', 4, '2020-08-17 08:30:34.167'),
(10, N'Aishia', N'Smith', 4, '2016-05-25 07:12:34.167')