CREATE TABLE [D011-10-1].[DSAHIST_OESIndsigt_Kontoplantekster](
  [KTOPDEL] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [TXTSTRUK] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [FBENAAR] [int] NULL,
  [SBENAAR] [int] NULL,
  [TXTLIN1] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [TXTLIN2] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [TXTLIN3] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [TXTLIN4] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [TXTLIN5] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [TXTLIN6] [varchar](100) 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,
  [STXTLIN1] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [STXTLIN2] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [STXTLIN3] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [TEKSTTYPE] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [TEKSTIOSTITXT] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [TXTLIN] [varchar](500) COLLATE Norwegian_100_CI_AS NULL,
  [KAPITAL] [varchar](50) 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([KTOPDEL],[TXTSTRUK],[FBENAAR],[SBENAAR],[TXTLIN1],[TXTLIN2],[TXTLIN3],[TXTLIN4],[TXTLIN5],[TXTLIN6],[RETUSRID],[OPRDAT],[OPRTID],[RETDAT],[RETTID],[STXTLIN1],[STXTLIN2],[STXTLIN3],[TEKSTTYPE],[TEKSTIOSTITXT],[TXTLIN],[KAPITAL])),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_D011-10-1_DSAHIST_OESIndsigt_Kontoplantekster] On [D011-10-1].[DSAHIST_OESIndsigt_Kontoplantekster] (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'Indeholder kontoplantekster', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'KTOPLANDEL: FDESGAPO', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'KTOPDEL';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'STRUKTURNR.', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'TXTSTRUK';
GO

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

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'TEKSTLINIE 1', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'TXTLIN1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'TEKSTLINIE 2', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'TXTLIN2';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'TEKSTLINIE 3', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'TXTLIN3';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'TEKSTLINIE 4', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'TXTLIN4';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'TEKSTLINIE 5', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'TXTLIN5';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'TEKSTLINIE 6', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'TXTLIN6';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'BRUGERID', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'RETUSRID';
GO

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

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

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

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

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

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

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

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

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Struktur tekst', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'TXTLIN';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Vis med store bogstaver', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'KAPITAL';
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'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@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'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@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'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@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'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@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'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@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'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@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'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@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'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster', 
@level2type = N'COLUMN', @level2name = N'SYS_Checksum';
GO

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

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'oekonomi', 
@level0type = N'SCHEMA', @level0name = N'D011-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_OESIndsigt_Kontoplantekster';
GO

