CREATE TABLE [KY].[DimKYOpgaveOversigtBenchmark](
  [DimKYOpgaveOversigtBenchmarkID] [bigint] NOT NULL,
  [Opgave_ID] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [OpgaveStatus] [varchar](30) COLLATE Norwegian_100_CI_AS NULL,
  [OpgaveTitel] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [OpgaveBeskrivelse] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [OpgaveType1_Delproces] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [OpgaveType2_Delproces] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [OpgaveType3_Delproces] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [AnsvarligForOpgaven] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [StartDato] [datetime2](3) NULL,
  [SlutDato] [datetime2](3) NULL,
  [SYS_KommuneId] [int] NULL,
  [SYS_BatchDate] [datetime2](3) NULL,
  [SYS_RowID] [bigint] identity(1,1) NOT NULL,
  [SYS_ExtractDate] [datetime2](3) NULL,
  [SYS_ExecutionId] [bigint] NULL,
  CONSTRAINT PK_DimKYOpgaveOversigtBenchmark PRIMARY KEY CLUSTERED (DimKYOpgaveOversigtBenchmarkID)
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE INDEX [IDX_Kommune_KY_DimKYOpgaveOversigtBenchmark]
On [KY].[DimKYOpgaveOversigtBenchmark] ([SYS_KommuneId], [SYS_ExecutionId])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder oplysninger på start og sluttidspunkter for alle opgaver uden brugervendtnøgle', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'DimKYOpgaveOversigtBenchmarkID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'Opgave_ID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'OpgaveStatus';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'OpgaveTitel';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'OpgaveBeskrivelse';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'OpgaveType1_Delproces';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'OpgaveType2_Delproces';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'OpgaveType3_Delproces';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'AnsvarligForOpgaven';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'StartDato';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'SlutDato';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder nummeret på den kommune, som rækken tilhører', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'SYS_KommuneId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder information om, hvilken batch rækken er indlæst i', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'SYS_BatchDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder et fortløbende nummer, så alle rækker i tabellen har et unikt nummer', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'SYS_RowID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder det dato stempel, som kildefilen er markeret med', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'SYS_ExtractDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SysExecutionId', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark', 
@level2type = N'COLUMN', @level2name = N'SYS_ExecutionId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'ky', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYOpgaveOversigtBenchmark';
GO

