CREATE TABLE [D140-11-2].[DSAHIST_04_PersonStatusEnrollment](
  [PersonStatusEnrollmentId] [int] NULL,
  [CivilRegistrationIdentifier] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [EnrollmentDate] [datetime2](3) NULL,
  [ClientCategoryTypeId] [int] NULL,
  [CurrentUnemploymentStatusId] [int] NULL,
  [UnemploymentFundId] [int] NULL,
  [UnemploymentFundBranchId] [int] NULL,
  [UnemploymentInsuranceCategoryId] [int] NULL,
  [RemovalDate] [datetime2](3) NULL,
  [RemovalCauseId] [int] NULL,
  [TagEnrolled] [int] NULL,
  [TagCancelled] [int] NULL,
  [EnrollmentIdentifier] [nvarchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [EnrollmentWarningDate] [datetime2](3) NULL,
  [EnrollmentWarningProcessed] [datetime2](3) NULL,
  [RemovalLetterCreated] [datetime2](3) NULL,
  [Jobnetflag] [bit] NULL,
  [NoSelfActivatingCodeNeeded] [bit] NULL,
  [EnrollmentWarningSourceDate] [datetime2](3) NULL,
  [EnrollmentWarningDateReminder] [datetime2](3) NULL,
  [Eventdate] [datetime2](3) NULL,
  [CreatedDateTime] [datetime2](3) NULL,
  [UpdatedDateTime] [datetime2](3) NULL,
  [RegistrationDateTime] [datetime2](3) NULL,
  [ActiveOrganisationTypeIdentifier] [smallint] NULL,
  [ActiveOrganisationCode] [int] NULL,
  [UserOrganisationTypeIdentifier] [smallint] NULL,
  [UserOrganisationCode] [int] NULL,
  [UserTypeIdentifier] [smallint] NULL,
  [UserFullName] [nvarchar](140) COLLATE Norwegian_100_CI_AS NULL,
  [IsLatest] [bit] 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([PersonStatusEnrollmentId],[CivilRegistrationIdentifier],[EnrollmentDate],[ClientCategoryTypeId],[CurrentUnemploymentStatusId],[UnemploymentFundId],[UnemploymentFundBranchId],[UnemploymentInsuranceCategoryId],[RemovalDate],[RemovalCauseId],[TagEnrolled],[TagCancelled],[EnrollmentIdentifier],[EnrollmentWarningDate],[EnrollmentWarningProcessed],[RemovalLetterCreated],[Jobnetflag],[NoSelfActivatingCodeNeeded],[EnrollmentWarningSourceDate],[EnrollmentWarningDateReminder],[Eventdate],[CreatedDateTime],[UpdatedDateTime],[RegistrationDateTime],[ActiveOrganisationTypeIdentifier],[ActiveOrganisationCode],[UserOrganisationTypeIdentifier],[UserOrganisationCode],[UserTypeIdentifier],[UserFullName],[IsLatest])),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_D140-11-2_DSAHIST_04_PersonStatusEnrollment] On [D140-11-2].[DSAHIST_04_PersonStatusEnrollment] (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'Person status tilmelding', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Internt id for tilmelding', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'PersonStatusEnrollmentId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'CPR nummer', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'CivilRegistrationIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tilmeldingsdato som arbejdsløs', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'EnrollmentDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Klienttype', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'ClientCategoryTypeId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angivelse af ledighedsgrad for borger ved registrering på fraværet', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'CurrentUnemploymentStatusId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Arbejdsløshedskassens id', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'UnemploymentFundId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Arbejdsløshedskassens afdelings id', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'UnemploymentFundBranchId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Arbejdsløshedsforsikringsgrad kategori id', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'UnemploymentInsuranceCategoryId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Frameldingsdato', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'RemovalDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Frameldingsårsag som arbejdsløs', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'RemovalCauseId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Send til jobcenter - gammel udgave', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'TagEnrolled';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Send til jobcenter annulleret - gammel udgave', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'TagCancelled';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Unikt id for tilmeldingen', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'EnrollmentIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Seneste dato for check af jobforslag', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'EnrollmentWarningDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Har advarsel har været behandlet, 1 betyder ja', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'EnrollmentWarningProcessed';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Har besked om framelding været genereret', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'RemovalLetterCreated';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borger har tilmeldt sig via jobnet', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'Jobnetflag';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Ingen selvaktiverende kode behøves', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'NoSelfActivatingCodeNeeded';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tidspunkt for advarsel for det nuværende', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'EnrollmentWarningSourceDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tidspunkt for advarsel om manglende check af jobforslag', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'EnrollmentWarningDateReminder';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Registreringstidspunkt i DFDG', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'Eventdate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Sættes når recorden oprettes', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'CreatedDateTime';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Sættes når recorden oprettes eller opdateres', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'UpdatedDateTime';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Registreringstidspunkt i kaldende system', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'RegistrationDateTime';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Den myndighed som der er registreret på vegne af (v/ AA: som brugeren har impersonated). Det er den ansvarlige myndighed', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'ActiveOrganisationTypeIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Koden som identificerer organisationen. Det kan være Jobcenternummer, et CVR nummer, en a-kassekode eller en kommunekode. Det er den ansvarlige myndighed', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'ActiveOrganisationCode';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kodeliste som identificerer typen af organisationen som brugeren hører til', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'UserOrganisationTypeIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Koden som identificerer organisationen som brugeren hører til. Det kan være et Jobcenternummer, CVR nummer, en a-kassekode eller en kommunekode', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'UserOrganisationCode';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kodeliste med brugertype', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'UserTypeIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Brugers fulde navn, ved systemkald angives systemets og jobbets navn her', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'UserFullName';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Markering af om tilmelding er nyeste', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'IsLatest';
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'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@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'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@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'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@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'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@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'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@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'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@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'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@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'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment', 
@level2type = N'COLUMN', @level2name = N'SYS_Checksum';
GO

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

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'dfdg', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_04_PersonStatusEnrollment';
GO

