CREATE TABLE [D060-14-2].[DSAHIST_DT_DST_IST_Eco](
  [Kommune] [smallint] NULL,
  [Periode] [bigint] NULL,
  [Betaler_CPR] [varchar](11) COLLATE Norwegian_100_CI_AS NULL,
  [Barn_CPR] [varchar](11) COLLATE Norwegian_100_CI_AS NULL,
  [Takst_start] [datetime2](3) NULL,
  [Takst_slut] [datetime2](3) NULL,
  [GrundTakst] [decimal](18,6) NULL,
  [Indkomst] [decimal](18,6) NULL,
  [Fradrag] [decimal](18,6) NULL,
  [SØRABBEL] [decimal](18,6) NULL,
  [SØRABPCT] [decimal](18,6) NULL,
  [ØKFRIBELØB] [decimal](18,6) NULL,
  [ØKFRIPCT] [decimal](18,6) NULL,
  [SOPÆDBEL] [decimal](18,6) NULL,
  [SOPÆDPCT] [decimal](18,6) NULL,
  [BEHANDLBEL] [decimal](18,6) NULL,
  [BEHANDLPCT] [decimal](18,6) NULL,
  [I_ALT_BELØB] [decimal](18,6) 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([Kommune],[Periode],[Betaler_CPR],[Barn_CPR],[Takst_start],[Takst_slut],[GrundTakst],[Indkomst],[Fradrag],[SØRABBEL],[SØRABPCT],[ØKFRIBELØB],[ØKFRIPCT],[SOPÆDBEL],[SOPÆDPCT],[BEHANDLBEL],[BEHANDLPCT],[I_ALT_BELØB])),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_D060-14-2_DSAHIST_DT_DST_IST_Eco] On [D060-14-2].[DSAHIST_DT_DST_IST_Eco] (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'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'Kommune';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'Periode';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'Betaler_CPR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'Barn_CPR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'Takst_start';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'Takst_slut';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'GrundTakst';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'Indkomst';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'Fradrag';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'SØRABBEL';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'SØRABPCT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'ØKFRIBELØB';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'ØKFRIPCT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'SOPÆDBEL';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'SOPÆDPCT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'BEHANDLBEL';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'BEHANDLPCT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'I_ALT_BELØB';
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'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@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'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@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'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@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'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@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'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@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'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@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'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@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'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco', 
@level2type = N'COLUMN', @level2name = N'SYS_Checksum';
GO

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

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'dagtilbud', 
@level0type = N'SCHEMA', @level0name = N'D060-14-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_IST_Eco';
GO

