CREATE TABLE [D160-12-1].[DSAHIST_KY_SagH](
  [Aendret] [datetime2](3) NULL,
  [Aendretaf] [varchar](200) COLLATE Norwegian_100_CI_AS NULL,
  [AfgoerendeMyndighed] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [Afleveret] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [AnsvarligOrgEnhedId] [varchar](36) COLLATE Norwegian_100_CI_AS NULL,
  [BrugervendtNoegle] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [Deaktiv] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [EyAyDetaljering] [varchar](36) COLLATE Norwegian_100_CI_AS NULL,
  [EyAyGodYdelseNoegle] [varchar](75) COLLATE Norwegian_100_CI_AS NULL,
  [GodtgoerelseId] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [GyldigFra] [datetime2](3) NULL,
  [GyldigTil] [datetime2](3) NULL,
  [Handlingsklasse] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [HarKlagesag] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [HarMellemkommunalrefusionssag] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [HistorikFra] [datetime2](3) NULL,
  [Id] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [ImporteretTilKombit] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [Kassationsdato] [datetime2](3) NULL,
  [Kassationskode] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [KleNr] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [KonvKleUuid] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [KonvOprindeligBevillingsdato] [datetime2](3) NULL,
  [ManuelGodkendelse] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [OplysningspligtLetter] [datetime2](3) NULL,
  [Oprettet] [datetime2](3) NULL,
  [Oprettetaf] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [PrimaerBehandlerOrgEnhedId] [varchar](36) COLLATE Norwegian_100_CI_AS NULL,
  [PrimaerBehandlerSfbrugerId] [varchar](36) COLLATE Norwegian_100_CI_AS NULL,
  [Principiel] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [Sagstilstand] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [Slettet] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [Ydelsesart] [varchar](1) 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([Aendret],[Aendretaf],[AfgoerendeMyndighed],[Afleveret],[AnsvarligOrgEnhedId],[BrugervendtNoegle],[Deaktiv],[EyAyDetaljering],[EyAyGodYdelseNoegle],[GodtgoerelseId],[GyldigFra],[GyldigTil],[Handlingsklasse],[HarKlagesag],[HarMellemkommunalrefusionssag],[HistorikFra],[Id],[ImporteretTilKombit],[Kassationsdato],[Kassationskode],[KleNr],[KonvKleUuid],[KonvOprindeligBevillingsdato],[ManuelGodkendelse],[OplysningspligtLetter],[Oprettet],[Oprettetaf],[PrimaerBehandlerOrgEnhedId],[PrimaerBehandlerSfbrugerId],[Principiel],[Sagstilstand],[Slettet],[Ydelsesart])),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_D160-12-1_DSAHIST_KY_SagH] On [D160-12-1].[DSAHIST_KY_SagH] (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'SagH', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Aendret';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Aendretaf';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'AfgoerendeMyndighed';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Afleveret';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'AnsvarligOrgEnhedId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'BrugervendtNoegle';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Deaktiv';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'EyAyDetaljering';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'EyAyGodYdelseNoegle';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'GodtgoerelseId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'GyldigFra';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'GyldigTil';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Handlingsklasse';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'HarKlagesag';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'HarMellemkommunalrefusionssag';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'HistorikFra';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Id';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'ImporteretTilKombit';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Kassationsdato';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Kassationskode';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'KleNr';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'KonvKleUuid';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'KonvOprindeligBevillingsdato';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'ManuelGodkendelse';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'OplysningspligtLetter';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Oprettet';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Oprettetaf';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'PrimaerBehandlerOrgEnhedId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'PrimaerBehandlerSfbrugerId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Principiel';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Sagstilstand';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Slettet';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'Ydelsesart';
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'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@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'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@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'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@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'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@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'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@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'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@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'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@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'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH', 
@level2type = N'COLUMN', @level2name = N'SYS_Checksum';
GO

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

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'ky', 
@level0type = N'SCHEMA', @level0name = N'D160-12-1', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_KY_SagH';
GO

