CREATE TABLE [D080-11-5].[DSAHIST_P02680_016_Myndighedsoplysning](
  [RECORDTYPE] [int] NULL,
  [MYNKOD] [int] NULL,
  [MINTYP] [int] NULL,
  [MINGRP] [int] NULL,
  [TIMESTAMP] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [MYNTLE] [int] NULL,
  [HAENSTART] [datetime2](3) NULL,
  [HAENSLUT_CTMYN] [datetime2](3) NULL,
  [MYNNVN] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [MYNADRSAT] [varchar](34) COLLATE Norwegian_100_CI_AS NULL,
  [ADR1] [varchar](34) COLLATE Norwegian_100_CI_AS NULL,
  [ADR2] [varchar](34) COLLATE Norwegian_100_CI_AS NULL,
  [ADR3] [varchar](34) COLLATE Norwegian_100_CI_AS NULL,
  [ADR4] [varchar](34) COLLATE Norwegian_100_CI_AS NULL,
  [TELEFAXNR] [varchar](8) COLLATE Norwegian_100_CI_AS NULL,
  [MYNNVN_XL] [varchar](60) COLLATE Norwegian_100_CI_AS NULL,
  [E_MAIL] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [LAND_KOD_ALFA2] [varchar](2) COLLATE Norwegian_100_CI_AS NULL,
  [LAND_KOD_ALFA3] [varchar](3) COLLATE Norwegian_100_CI_AS NULL,
  [LAND_KOD_NUM3] [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_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([RECORDTYPE],[MYNKOD],[MINTYP],[MINGRP],[TIMESTAMP],[MYNTLE],[HAENSTART],[HAENSLUT_CTMYN],[MYNNVN],[MYNADRSAT],[ADR1],[ADR2],[ADR3],[ADR4],[TELEFAXNR],[MYNNVN_XL],[E_MAIL],[LAND_KOD_ALFA2],[LAND_KOD_ALFA3],[LAND_KOD_NUM3])),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_D080-11-5_DSAHIST_P02680_016_Myndighedsoplysning] On [D080-11-5].[DSAHIST_P02680_016_Myndighedsoplysning] (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'Myndighedsoplysning', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Lig tre sidste cifre af record-navn', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'RECORDTYPE';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'myndighedskode', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'MYNKOD';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Myndighedstype', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'MINTYP';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Myndighedsgruppe', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'MINGRP';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Ajourføringstidspunktet', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'TIMESTAMP';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Myndighedstelefon', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'MYNTLE';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Startdato ÅÅÅÅMMDDTTMM', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'HAENSTART';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Myndighed slutdato', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'HAENSLUT_CTMYN';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Myndighedsnavn', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'MYNNVN';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Myndighedsadressat', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'MYNADRSAT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Adresselinie 1', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'ADR1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Adresselinie 2', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'ADR2';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Adresselinie 3', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'ADR3';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Adresselinie 4', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'ADR4';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Telefax nummer', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'TELEFAXNR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Myndighedensnavn fuld længde', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'MYNNVN_XL';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Myndighed Email', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'E_MAIL';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Myndighed Landekode', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'LAND_KOD_ALFA2';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Myndighed Landekode', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'LAND_KOD_ALFA3';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Myndighed Landekode', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'LAND_KOD_NUM3';
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'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@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'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@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'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@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'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@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'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@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'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@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'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@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'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'SYS_Checksum';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SysExecutionId', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'SYS_ExecutionId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SysDataDeliveryBatchIdCreate', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning', 
@level2type = N'COLUMN', @level2name = N'SYS_DataDeliveryBatchId_Create';
GO

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'borger', 
@level0type = N'SCHEMA', @level0name = N'D080-11-5', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P02680_016_Myndighedsoplysning';
GO

