CREATE TABLE [KY].[FactKYSager](
  [FactKYSagerID] [bigint] NULL,
  [Sag_ID] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [DimTid] [bigint] NULL,
  [DimJaNejOprettet] [bigint] NULL,
  [DimJaNejAfsluttetSagsbehandling] [bigint] NULL,
  [DimJaNejAfsluttetSag] [bigint] NULL,
  [Sagsbehandlingstid] [decimal](16,2) NULL,
  [Sag_Varighed] [decimal](16,2) NULL,
  [DimKommune] [bigint] NULL,
  [DimKYSagsbehandler] [bigint] NULL,
  [DimKYOrganisation] [bigint] NULL,
  [DimKYSagOversigt] [bigint] NULL,
  [DimBorger_Bevillingsmodtager] [bigint] NULL,
  [DimBorger_Ydelsesmodtager] [bigint] NULL,
  [DimKYYdelsesart] [bigint] NULL,
  [DimKYKleNummer] [bigint] NULL,
  [DimKYAfgørelsestype] [bigint] NULL,
  [DimKYOpgaveOversigt] [bigint] NULL,
  [DimJaNejOprettetOpgave] [bigint] NULL,
  [DimJaNejAfsluttetOpgave] [bigint] NULL,
  [Opgave_Varighed] [decimal](16,2) NULL,
  [Opgavevarighed_Sagsbehandler] [decimal](16,2) NULL,
  [Opgavevarighed_Borger] [decimal](16,2) NULL,
  [SagMarkørID] [bigint] 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_FactKYSager]
On [KY].[FactKYSager] ([SYS_KommuneId], [SYS_RowID])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder oplysninger på alle  sager udrullet på måned', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'FactKYSager';
GO

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

