· 9 years ago · Dec 13, 2016, 03:11 AM
1USE SSISDB
2GO
3
4-- Create [toolbelt] schema if it does not yet exist
5IF NOT EXISTS (SELECT 1 FROM sys.schemas WHERE name = 'toolbelt')
6 EXEC sp_executesql N'CREATE SCHEMA [toolbelt]'
7GO
8
9-- Drop table if exists
10IF EXISTS (SELECT 1 FROM sys.tables WHERE OBJECT_ID = OBJECT_ID('[toolbelt].[Exec_Status]'))
11 DROP TABLE [toolbelt].[Exec_Status]
12GO
13
14-- Create table
15CREATE TABLE [toolbelt].[Exec_Status]
16(
17 status_id INT NOT NULL
18 , status_name VARCHAR(50) NOT NULL
19 , status_group VARCHAR(50) NOT NULL
20)
21GO
22
23-- Populate with status values
24INSERT [toolbelt].[Exec_Status]
25VALUES (1, 'Created', 'Active')
26 , (2, 'Running', 'Active')
27 , (3, 'Canceled', 'Failed')
28 , (4, 'Failed', 'Failed')
29 , (5, 'Pending', 'Active')
30 , (6, 'Ended unexpectedly', 'Failed')
31 , (7, 'Succeeded', 'Succeeded')
32 , (8, 'Stopping', 'Active')
33 , (9, 'Completed', 'Failed')
34GO
35
36-- Create clustered PK on status_id
37ALTER TABLE [toolbelt].[Exec_Status] ADD CONSTRAINT [PK_Exec_Status] PRIMARY KEY CLUSTERED
38(
39 [status_id] ASC
40)
41GO
42
43-- Create index on status name
44CREATE UNIQUE INDEX ix_exec_status_name
45ON [toolbelt].[Exec_Status] (status_name)
46GO