· 6 years ago · Jun 14, 2019, 11:07 AM
1-- Create a new table called '[Events]' in schema '[dbo]'
2-- Drop the table if it already exists
3DROP TABLE IF EXISTS [dbo].[Events]
4GO
5-- Create the table in the specified schema
6CREATE TABLE [dbo].[Events]
7(
8 [Id] INT NOT NULL PRIMARY KEY IDENTITY, -- Primary Key column
9 [ImportTypeId] INT NULL
10 REFERENCES [dbo].[ImportTypes](Id),
11 [ImportId] NVARCHAR(50) NULL,
12 [Title] NVARCHAR(512) NOT NULL,
13 [Description] NVARCHAR(2048) NOT NULL,
14
15 CONSTRAINT UQ_Events UNIQUE (ImportId, ImportTypeId),
16 INDEX IX_EventTitle ([Title] ASC)
17);
18GO
19
20-- Create a new table called '[Events]' in schema '[eventful]'
21-- Drop the table if it already exists
22DROP TABLE IF EXISTS [eventful].[Events]
23GO
24-- Create the table in the specified schema
25CREATE TABLE [eventful].[Events]
26(
27 [EventfulId] NVARCHAR(50) NOT NULL
28 REFERENCES [dbo].[Events](ImportId),
29 [ImportDate] DATETIME NOT NULL DEFAULT(GETUTCDATE()),
30 [LastImportDate] DATETIME NULL,
31 [Url] NVARCHAR(2048) NULL,
32
33 CONSTRAINT PK_EventfulEvents PRIMARY KEY CLUSTERED (EventfulId)
34);
35GO
36
37REFERENCES [dbo].[Events](ImportId)