CREATE TABLE [KY].[FactKYYdelserBenchmark](
  [FactKYYdelserBenchmarkID] [bigint] identity(1,1) NOT NULL,
  [DimTid] [bigint] NULL,
  [Fuldtid] [decimal](8,2) NULL,
  [PmarkørID_Bevillingsmodtager] [bigint] NULL,
  [PmarkørID_Ydelsesmodtager] [bigint] NULL,
  [DimKYYdelsestype] [bigint] NULL,
  [DimKYYdelsesart] [bigint] NULL,
  [DimKYKleNummer] [bigint] NULL,
  [DimKommune] [bigint] NULL,
  [DimKYSagOversigtBenchmark] [bigint] NULL,
  [DimKYAfgørelsestype] [bigint] NULL,
  [SYS_KommuneId] [int] NULL,
  [SYS_BatchDate] [datetime2](3) NULL,
  [SYS_RowID] AS ([FactKYYdelserBenchmarkID]) ,
  [SYS_ExtractDate] [datetime2](3) NULL,
  [SYS_ExecutionId] [bigint] NULL
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE UNIQUE CLUSTERED INDEX [IDX_CL_KY_FactKYYdelserBenchmark]
On [KY].[FactKYYdelserBenchmark] ([SYS_KommuneId], [FactKYYdelserBenchmarkID])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder oplysninger på bevilgetydelser på måned - benchmark', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'FactKYYdelserBenchmark';
GO

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

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

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

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

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

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

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

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

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

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'FactKYYdelserBenchmark', 
@level2type = N'COLUMN', @level2name = N'DimKYAfgørelsestype';
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'FactKYYdelserBenchmark', 
@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'FactKYYdelserBenchmark', 
@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'FactKYYdelserBenchmark', 
@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'FactKYYdelserBenchmark', 
@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'FactKYYdelserBenchmark', 
@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'FactKYYdelserBenchmark';
GO

