CREATE TABLE [D060-14-4].[DSAHIST_DT_DST_KMDi2_Indmeldelsestakst](
  [KOMNR] [smallint] NULL,
  [INST_ID] [bigint] NULL,
  [Daginstitutionsnummer] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [BookingId] [bigint] NULL,
  [StartDate] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [EndDate] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [PNRINSTB] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [PrimaryPayer] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [SecondaryPayer] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [ØKFRIPCT] [decimal](18,6) NULL,
  [ØKFRIBELØB] [decimal](18,6) NULL,
  [SØRABPCT] [decimal](18,6) NULL,
  [SØRABBEL] [decimal](18,6) NULL,
  [SOPÆDPCT] [decimal](18,6) NULL,
  [SOPÆDBEL] [decimal](18,6) NULL,
  [TreatmentSubsidyPercent] [decimal](18,6) NULL,
  [TreatmentSubsidyAmount] [decimal](18,6) NULL,
  [PrivateInstitutionSubsidies] [decimal](18,6) NULL,
  [DRIFTSUDGIFT] [decimal](18,6) NULL,
  [BRUTTOTAKST] [decimal](18,6) NULL,
  [HUSINDKOMST] [decimal](18,6) NULL,
  [FRADRAG_ENLIG] [decimal](18,6) NULL,
  [FRADRAG_BØRN] [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([KOMNR],[INST_ID],[Daginstitutionsnummer],[BookingId],[StartDate],[EndDate],[PNRINSTB],[PrimaryPayer],[SecondaryPayer],[ØKFRIPCT],[ØKFRIBELØB],[SØRABPCT],[SØRABBEL],[SOPÆDPCT],[SOPÆDBEL],[TreatmentSubsidyPercent],[TreatmentSubsidyAmount],[PrivateInstitutionSubsidies],[DRIFTSUDGIFT],[BRUTTOTAKST],[HUSINDKOMST],[FRADRAG_ENLIG],[FRADRAG_BØRN])),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-4_DSAHIST_DT_DST_KMDi2_Indmeldelsestakst] On [D060-14-4].[DSAHIST_DT_DST_KMDi2_Indmeldelsestakst] (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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kommunenummer', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'KOMNR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Institutionsid (""skjult"" nøgle). Findes i kommunernes fagsystem.', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'INST_ID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Institutionsnummer til dagtilbudsregisteret i BUVM', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'Daginstitutionsnummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Unik Booking identifikation', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'BookingId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Startdato for booking - ddmmyyyy', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'StartDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Slutdato for booking - ddmmyyyy', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'EndDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'CPR Barns', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'PNRINSTB';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'CPR primær betaler', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'PrimaryPayer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'CPR sekundær betaler', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'SecondaryPayer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Økonomisk friplads i % - ""."" læses som "",""', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'ØKFRIPCT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Øko friplads beløb  - ""."" læses som "",""', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'ØKFRIBELØB';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Søskenderabat i % - ""."" læses som "",""', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'SØRABPCT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Søskenderabat beløb -  ""."" læses som "",""', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'SØRABBEL';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Socialpædagogisk friplads i % -  ""."" læses som "",""', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'SOPÆDPCT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Socialpædagogisk friplads beløb - ""."" læses som "",""', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'SOPÆDBEL';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Behandlingsmæssig friplads i % -  ""."" læses som "",""', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'TreatmentSubsidyPercent';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Behandlingsmæssig friplads I beløb  -  ""."" læses som "",""', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'TreatmentSubsidyAmount';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tilskud til privatinstitution i beløb -  ""."" læses som "",""', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'PrivateInstitutionSubsidies';
GO

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

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

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

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D060-14-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@level2type = N'COLUMN', @level2name = N'FRADRAG_BØRN';
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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst', 
@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-4', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_DT_DST_KMDi2_Indmeldelsestakst';
GO

