CREATE TABLE [D010-10-2].[DSAHIST_Prisme15_Finansposter](
  [BilagNr] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [Dato] [datetime2](3) NULL,
  [Type] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim1] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim2] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim3] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim4] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim5] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim6] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim7] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim8] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim9] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim10] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim11] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Oeko_Dim12] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [F1] [int] NULL,
  [F2] [int] NULL,
  [F3] [int] NULL,
  [D1] [int] NULL,
  [E1] [int] NULL,
  [O1] [int] NULL,
  [G1] [int] NULL,
  [A1] [int] NULL,
  [A2] [int] NULL,
  [Beløb] [decimal](15,2) NULL,
  [Ydelsesmodtager] [varchar](11) COLLATE Norwegian_100_CI_AS NULL,
  [Kommentar] [varchar](300) COLLATE Norwegian_100_CI_AS NULL,
  [OprettetDatoTid] [datetime2](3) NULL,
  [OprettetAf] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [KontrolleretAf] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [KontrolleretDato] [datetime2](3) NULL,
  [SD_Transaktionsnummer] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Maskinnr] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Valuta] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Kladdenummer] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [BetalingsModtagerNummer] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [BetalingsModtagerNummerKode] [varchar](20) 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([BilagNr],[Dato],[Type],[Oeko_Dim1],[Oeko_Dim2],[Oeko_Dim3],[Oeko_Dim4],[Oeko_Dim5],[Oeko_Dim6],[Oeko_Dim7],[Oeko_Dim8],[Oeko_Dim9],[Oeko_Dim10],[Oeko_Dim11],[Oeko_Dim12],[F1],[F2],[F3],[D1],[E1],[O1],[G1],[A1],[A2],[Beløb],[Ydelsesmodtager],[Kommentar],[OprettetDatoTid],[OprettetAf],[KontrolleretAf],[KontrolleretDato],[SD_Transaktionsnummer],[Maskinnr],[Valuta],[Kladdenummer],[BetalingsModtagerNummer],[BetalingsModtagerNummerKode])),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_D010-10-2_DSAHIST_Prisme15_Finansposter] On [D010-10-2].[DSAHIST_Prisme15_Finansposter] (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 posteringsdata.', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'BilagNr';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Dato';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Type';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim2';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim3';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim4';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim5';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim6';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim7';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim8';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim9';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim10';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim11';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Oeko_Dim12';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'F1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'F2';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'F3';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'D1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'E1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'O1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'G1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'A1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'A2';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Beløb';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Ydelsesmodtager';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Kommentar';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'OprettetDatoTid';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'OprettetAf';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'KontrolleretAf';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'KontrolleretDato';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'SD_Transaktionsnummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Maskinnr';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Valuta';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'Kladdenummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'BetalingsModtagerNummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'BetalingsModtagerNummerKode';
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'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@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'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@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'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@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'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@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'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@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'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@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'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@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'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter', 
@level2type = N'COLUMN', @level2name = N'SYS_Checksum';
GO

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

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'oekonomi', 
@level0type = N'SCHEMA', @level0name = N'D010-10-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme15_Finansposter';
GO

