CREATE TABLE [D190-10-2].[DSAHIST_KRL_Fravaer](
  [Ym] [int] NULL,
  [MndYm] [int] NULL,
  [Cpr] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [Brnr] [varchar](4) COLLATE Norwegian_100_CI_AS NULL,
  [Mnummer] [int] NULL,
  [Fra] [datetime2](3) NULL,
  [Til] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [DagePeriode] [smallint] NULL,
  [DageMnd] [smallint] NULL,
  [FvtimerPeriode] [decimal](24,16) NULL,
  [FvtimerMnd] [decimal](24,16) NULL,
  [Type] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [Aarsag] [int] NULL,
  [StartetDenneMnd] [bit] NULL,
  [Uafsluttet] [bit] NULL,
  [SYS_KommuneId] [int] NULL,
  [SYS_BatchDate] [datetime2](3) NULL,
  [SYS_RowID] [bigint] identity(1,1) NOT NULL,
  [SYS_ExtractDate] [datetime2](3) NULL,
  [SYS_SourceFileID] [varchar](80) COLLATE Norwegian_100_CI_AS NULL,
  [SYS_RettelserTidAngivelse] [datetime2](3) NULL,
  [SYS_VersionID] [bigint] NULL,
  [SYS_Checksum] AS (CONVERT([bigint],hashbytes('SHA2_256',concat([Ym],[MndYm],[Cpr],[Brnr],[Mnummer],[Fra],[Til],[DagePeriode],[DageMnd],[FvtimerPeriode],[FvtimerMnd],[Type],[Aarsag],[StartetDenneMnd],[Uafsluttet])),0)) PERSISTED,
  [SYS_ExecutionId] [bigint] NULL,
  [SYS_DataDeliveryBatchId_Create] [bigint] NULL
) 
on sys_batch_date_sc(SYS_BatchDate)
GO

CREATE UNIQUE CLUSTERED INDEX [IDX_CL_D190-10-2_DSAHIST_KRL_Fravaer] On [D190-10-2].[DSAHIST_KRL_Fravaer] (SYS_BatchDate, SYS_KommuneId, SYS_RowID) with (data_compression = page, STATISTICS_INCREMENTAL = ON) on sys_batch_date_sc(SYS_BatchDate);
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder KRLs behandlede fraværsdata fra KMD og Silkeborg data.', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'Ym';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'MndYm';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'Cpr';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'Brnr';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'Mnummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'Fra';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'Til';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'DagePeriode';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'DageMnd';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'FvtimerPeriode';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'FvtimerMnd';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'Type';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'Aarsag';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'StartetDenneMnd';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'Uafsluttet';
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'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@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'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@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'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@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'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'SYS_ExtractDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder ID for den primære snitflade, hvor data i rækken stammer fra', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'SYS_SourceFileID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder den forretningsmæssige tidsangivelse for rækken. Denne bruges hvis data skal slettes med tidsangivelse', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'SYS_RettelserTidAngivelse';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder et versionsnummer for den pågældende række', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'SYS_VersionID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dette er en teknisk Kolonne i FLIS. Indeholder cheksum info', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'SYS_Checksum';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SysExecutionId', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'SYS_ExecutionId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SysDataDeliveryBatchIdCreate', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer', 
@level2type = N'COLUMN', @level2name = N'SYS_DataDeliveryBatchId_Create';
GO

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'personale', 
@level0type = N'SCHEMA', @level0name = N'D190-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KRL_Fravaer';
GO

