CREATE TABLE [D080-11-2].[DSAHIST_P12170_002_Aktuelle_adresseoplysninger](
  [RECORDTYPE] [int] NULL,
  [PNR] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [KOMKOD] [varchar](4) COLLATE Norwegian_100_CI_AS NULL,
  [VEJKOD] [varchar](4) COLLATE Norwegian_100_CI_AS NULL,
  [HUSNR] [varchar](4) COLLATE Norwegian_100_CI_AS NULL,
  [ETAGE] [varchar](2) COLLATE Norwegian_100_CI_AS NULL,
  [SIDEDOER] [varchar](4) COLLATE Norwegian_100_CI_AS NULL,
  [BNR] [varchar](4) COLLATE Norwegian_100_CI_AS NULL,
  [CONVN] [varchar](34) COLLATE Norwegian_100_CI_AS NULL,
  [TILFLYDTO] [datetime2](3) NULL,
  [TILFLYDTO_UMRK] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [TILFLYKOMDTO] [datetime2](3) NULL,
  [TILFLYKOMDT_UMRK] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [FRAFLYKOMKOD] [int] NULL,
  [FRAFLYKOMDTO] [datetime2](3) NULL,
  [FRAFLYKOMDT_UMRK] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [START_MYNKOD_ADRTXT] [int] NULL,
  [ADR1_SUPLADR] [varchar](34) COLLATE Norwegian_100_CI_AS NULL,
  [ADR2_SUPLADR] [varchar](34) COLLATE Norwegian_100_CI_AS NULL,
  [ADR3_SUPLADR] [varchar](34) COLLATE Norwegian_100_CI_AS NULL,
  [ADR4_SUPLADR] [varchar](34) COLLATE Norwegian_100_CI_AS NULL,
  [ADR5_SUPLADR] [varchar](34) COLLATE Norwegian_100_CI_AS NULL,
  [START_DT_ADRTXT] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [SLET_DT_ADRTXT] [varchar](10) COLLATE Norwegian_100_CI_AS 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],[PNR],[KOMKOD],[VEJKOD],[HUSNR],[ETAGE],[SIDEDOER],[BNR],[CONVN],[TILFLYDTO],[TILFLYDTO_UMRK],[TILFLYKOMDTO],[TILFLYKOMDT_UMRK],[FRAFLYKOMKOD],[FRAFLYKOMDTO],[FRAFLYKOMDT_UMRK],[START_MYNKOD_ADRTXT],[ADR1_SUPLADR],[ADR2_SUPLADR],[ADR3_SUPLADR],[ADR4_SUPLADR],[ADR5_SUPLADR],[START_DT_ADRTXT],[SLET_DT_ADRTXT])),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-2_DSAHIST_P12170_002_Aktuelle_adresseoplysninger] On [D080-11-2].[DSAHIST_P12170_002_Aktuelle_adresseoplysninger] (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'Aktuelle adresseoplysninger', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger';
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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'RECORDTYPE';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Personnummer', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'PNR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kommunekode', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'KOMKOD';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Vejkode', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'VEJKOD';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Husnummer', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'HUSNR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Etage', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'ETAGE';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Sidedør nummer', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'SIDEDOER';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Bygningsnummer', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'BNR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'C/O navn', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'CONVN';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tilflytningsdato ÅÅÅÅMMDDTTMM', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'TILFLYDTO';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tilflytningsdato usikkerhedsmarkering', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'TILFLYDTO_UMRK';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tilflytning kommune dato ÅÅÅÅMMDDTTMM', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'TILFLYKOMDTO';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tilflytning kommune dato usikkerhedsmarkering', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'TILFLYKOMDT_UMRK';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fraflytning kommunekode', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'FRAFLYKOMKOD';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fraflytning kommune dato ÅÅÅÅMMDDTTMM', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'FRAFLYKOMDTO';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fraflytning kommune dato usikkerhedsmarkering', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'FRAFLYKOMDT_UMRK';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Start myndighed', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'START_MYNKOD_ADRTXT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'1. linie af supplerende adr', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'ADR1_SUPLADR';
GO

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

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

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

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Startdato ÅÅÅÅ-MM-DD', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'START_DT_ADRTXT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Slettedato ÅÅÅÅ-MM-DD', 
@level0type = N'SCHEMA', @level0name = N'D080-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@level2type = N'COLUMN', @level2name = N'SLET_DT_ADRTXT';
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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger', 
@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-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_P12170_002_Aktuelle_adresseoplysninger';
GO

