CREATE TABLE [KY].[FactKYYdelseudbetalingRefusion](
  [FactKYYdelseudbetalingRefusionID] [bigint] NULL,
  [DimKYYdelsesart] [bigint] NULL,
  [DimKYYdelsestype] [bigint] NULL,
  [AtpBorger] [decimal](18,6) NULL,
  [AtpKommune] [decimal](18,6) NULL,
  [BeløbEfterAtp] [decimal](18,6) NULL,
  [BeløbTilTilbagebetaling] [decimal](18,6) NULL,
  [DimPeriodeStartDatoTid] [bigint] NULL,
  [DimPeriodeSlutDatoTid] [bigint] NULL,
  [Finansieringsbeløb] [decimal](10,2) NULL,
  [IndberetningUdbetalingsbeløb] [decimal](10,2) NULL,
  [YdelseSTAR] [varchar](150) COLLATE Norwegian_100_CI_AS NULL,
  [DimKommuneFinansieringsKommune] [bigint] NULL,
  [DimBorger] [bigint] NULL,
  [Kontol] [int] 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
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE UNIQUE CLUSTERED INDEX [IDX_CL_KY_FactKYYdelseudbetalingRefusion]
On [KY].[FactKYYdelseudbetalingRefusion] ([SYS_KommuneId], [SYS_RowID])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder oplysninger på ydelsesudbetaling og refusion', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'FactKYYdelseudbetalingRefusion';
GO

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

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

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

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

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

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

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

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

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

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

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

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

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

