CREATE TABLE [D110-10-1].[DSAHIST_OESIndsigt_OesKontoplanerAar](
  [Regnskabsår] [int] NULL,
  [STRUKNR] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [FUNK] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [DRANST] [int] NULL,
  [EJER] [int] NULL,
  [STEDER] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [GRUPPER] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [ARTER] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [KTONR] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [POLORG] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [ADMORG] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [MOMSKOD] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [STATHEN] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [FBENAAR] [varchar](4) COLLATE Norwegian_100_CI_AS NULL,
  [SBENAAR] [int] NULL,
  [FRADATO] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [TILDATO] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [PENSKOD] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [SOCRKOD] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [SKATKOD] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [LIKVKOD] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [ANLOPL] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [EXPKOD] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [RETUSRID] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [OPRDAT] [datetime2](3) NULL,
  [OPRTID] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [RETDAT] [datetime2](3) NULL,
  [RETTID] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [INSTNR] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [PROJEKT] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [IMGRUPPE] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [SBESTDATO] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [FELT68KODE] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [FRIPLANDELX] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [FRIPLANDELZ] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [ORGANISATION] [varchar](200) 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([Regnskabsår],[STRUKNR],[FUNK],[DRANST],[EJER],[STEDER],[GRUPPER],[ARTER],[KTONR],[POLORG],[ADMORG],[MOMSKOD],[STATHEN],[FBENAAR],[SBENAAR],[FRADATO],[TILDATO],[PENSKOD],[SOCRKOD],[SKATKOD],[LIKVKOD],[ANLOPL],[EXPKOD],[RETUSRID],[OPRDAT],[OPRTID],[RETDAT],[RETTID],[INSTNR],[PROJEKT],[IMGRUPPE],[SBESTDATO],[FELT68KODE],[FRIPLANDELX],[FRIPLANDELZ],[ORGANISATION])),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_D110-10-1_DSAHIST_OESIndsigt_OesKontoplanerAar] On [D110-10-1].[DSAHIST_OESIndsigt_OesKontoplanerAar] (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'Kontoplaner fra ØS Indsigt spredt ud med en række per regnskabsår. Kontoplanerne er indlæst fra kilden strukturkonto', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Gældende regnskabsår udledt på baggrund af FBENAAR og SBENAAR', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'Regnskabsår';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SAMLET STRUKTURNR.', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'STRUKNR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'FUNKTION', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'FUNK';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'DRANST', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'DRANST';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'EJERFORHOLD', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'EJER';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'STED', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'STEDER';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'GRUPPERING', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'GRUPPER';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'ART', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'ARTER';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'KONTONR.', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'KTONR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'POLITISK ORGANISATION', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'POLORG';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'ADMINISTRATIV ORGANISATION', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'ADMORG';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'MOMSKODE', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'MOMSKOD';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'STATUSHENVISNINGNR.', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'STATHEN';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'FØRSTE BENYT.ÅR', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'FBENAAR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SIDSTE BENYT.ÅR', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'SBENAAR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'FRA BOGF.DATO', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'FRADATO';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'TIL BOGF.DATO', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'TILDATO';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'PENSIONSKODE', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'PENSKOD';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SOC.REG.KODE', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'SOCRKOD';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SKATTEPL.KODE', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'SKATKOD';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'LIKVIDITETSKODE', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'LIKVKOD';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'ANLAEGSOPLYSNINGER', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'ANLOPL';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'EXPORT AF POSTERINGER', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'EXPKOD';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'AENDRET AF', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'RETUSRID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'OPRETTET DATO', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'OPRDAT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'OPRETTET TID', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'OPRTID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'RETTET DATO', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'RETDAT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'RETTET TID', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'RETTID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'INSTITUTIONSNUMMER', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'INSTNR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'PROJEKT ORGANISATION', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'PROJEKT';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'IMGRUPPE', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'IMGRUPPE';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SIDSTE BESTILLINGSDATO', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'SBESTDATO';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'(null)', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'FELT68KODE';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fri kontoplandel X', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'FRIPLANDELX';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fri kontoplandel Z', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'FRIPLANDELZ';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Organisation som del af noegle', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'ORGANISATION';
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'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@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'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@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'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@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'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@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'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@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'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@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'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@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'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar', 
@level2type = N'COLUMN', @level2name = N'SYS_Checksum';
GO

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

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'generel', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_OesKontoplanerAar';
GO

