CREATE TABLE [D110-10-1].[DSAHIST_Prisme_Administrativ_organisation_tekster_](
  [U1] [varchar](25) COLLATE Norwegian_100_CI_AS NULL,
  [U2] [varchar](25) COLLATE Norwegian_100_CI_AS NULL,
  [U3] [varchar](25) COLLATE Norwegian_100_CI_AS NULL,
  [U4] [varchar](25) COLLATE Norwegian_100_CI_AS NULL,
  [U5] [varchar](25) COLLATE Norwegian_100_CI_AS NULL,
  [U6] [varchar](25) COLLATE Norwegian_100_CI_AS NULL,
  [U7] [varchar](25) COLLATE Norwegian_100_CI_AS NULL,
  [TEKST] [varchar](200) COLLATE Norwegian_100_CI_AS NULL,
  [STARTÅR] [datetime2](3) NULL,
  [Regnskabsår] [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([U1],[U2],[U3],[U4],[U5],[U6],[U7],[TEKST],[STARTÅR],[Regnskabsår])),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_Prisme_Administrativ_organisation_tekster_] On [D110-10-1].[DSAHIST_Prisme_Administrativ_organisation_tekster_] (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'Tabel med tekster for det administrative organisationshierarki for Prisme fordelt på regnskabsår', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme_Administrativ_organisation_tekster_';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Værdien af Administrativ organisation 1. niveau', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme_Administrativ_organisation_tekster_', 
@level2type = N'COLUMN', @level2name = N'U1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Værdien af Administrativ organisation 2. niveau', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme_Administrativ_organisation_tekster_', 
@level2type = N'COLUMN', @level2name = N'U2';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Værdien af Administrativ organisation 3. niveau', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme_Administrativ_organisation_tekster_', 
@level2type = N'COLUMN', @level2name = N'U3';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Værdien af Administrativ organisation 4. niveau', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme_Administrativ_organisation_tekster_', 
@level2type = N'COLUMN', @level2name = N'U4';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Værdien af Administrativ organisation 5. niveau', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme_Administrativ_organisation_tekster_', 
@level2type = N'COLUMN', @level2name = N'U5';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Værdien af Administrativ organisation 6. niveau', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme_Administrativ_organisation_tekster_', 
@level2type = N'COLUMN', @level2name = N'U6';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Værdien af Administrativ organisation 7. niveau', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme_Administrativ_organisation_tekster_', 
@level2type = N'COLUMN', @level2name = N'U7';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Den til niveauet hørende tekst', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme_Administrativ_organisation_tekster_', 
@level2type = N'COLUMN', @level2name = N'TEKST';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Den dato fra hvornår teksten gælder', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme_Administrativ_organisation_tekster_', 
@level2type = N'COLUMN', @level2name = N'STARTÅR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Regnskabsåret hvor kontoen er gældende', 
@level0type = N'SCHEMA', @level0name = N'D110-10-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_Prisme_Administrativ_organisation_tekster_', 
@level2type = N'COLUMN', @level2name = N'Regnskabsår';
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_Prisme_Administrativ_organisation_tekster_', 
@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_Prisme_Administrativ_organisation_tekster_', 
@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_Prisme_Administrativ_organisation_tekster_', 
@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_Prisme_Administrativ_organisation_tekster_', 
@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_Prisme_Administrativ_organisation_tekster_', 
@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_Prisme_Administrativ_organisation_tekster_', 
@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_Prisme_Administrativ_organisation_tekster_', 
@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_Prisme_Administrativ_organisation_tekster_', 
@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_Prisme_Administrativ_organisation_tekster_', 
@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_Prisme_Administrativ_organisation_tekster_', 
@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_Prisme_Administrativ_organisation_tekster_';
GO

