CREATE TABLE [D140-11-2].[DSAHIST_02_ActivityCompanyItemHistory](
  [Id] [int] NULL,
  [PlanVersionIdentifier] [nvarchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [ActivityCompanyItemId] [int] NULL,
  [ActivityCoreItemId] [int] NULL,
  [DiscoWeb] [int] NULL,
  [JobOrderIdentifier] [int] NULL,
  [JobTypeIdentifier] [int] NULL,
  [MinisterialDepartmentTypeIdentifier] [int] NULL,
  [FlexJobEmploymentTypeIdentifier] [int] NULL,
  [ChangeTypeId] [int] NULL,
  [ChangeDate] [datetime2](3) NULL,
  [PlanVersionTypeId] [int] NULL,
  [JobOrderPriceHourTypeIdentifier] [int] NULL,
  [AvailabilityProving] [bit] NULL,
  [JobAllocationTypeIdentifier] [int] NULL,
  [PersonId] [int] NULL,
  [PurposeOfCompanyInternshipTypeIdentifier] [int] NULL,
  [EmploymentGoalAliasIdentifier] [int] NULL,
  [EmploymentGoalConceptUriDa] [nvarchar](256) 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([Id],[PlanVersionIdentifier],[ActivityCompanyItemId],[ActivityCoreItemId],[DiscoWeb],[JobOrderIdentifier],[JobTypeIdentifier],[MinisterialDepartmentTypeIdentifier],[FlexJobEmploymentTypeIdentifier],[ChangeTypeId],[ChangeDate],[PlanVersionTypeId],[JobOrderPriceHourTypeIdentifier],[AvailabilityProving],[JobAllocationTypeIdentifier],[PersonId],[PurposeOfCompanyInternshipTypeIdentifier],[EmploymentGoalAliasIdentifier],[EmploymentGoalConceptUriDa])),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_02_ActivityCompanyItemHistory] On [D140-11-2].[DSAHIST_02_ActivityCompanyItemHistory] (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'Historik : Indeholder virksomhedsrettet aktivitetsdetaljer. Er denne type til stede er aktiviteten af typen ’virksomhed’', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Relation til PlanVersion', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'PlanVersionIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Relation til ActivityCompanyItem', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'ActivityCompanyItemId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Relation til ActivityCoreItem', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'ActivityCoreItemId';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Relation til JobOrder', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'JobOrderIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kodeliste værdi fra DFDG. (JobOrderType)', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'JobTypeIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kodeliste værdi fra DFDG. (Ministerområde)', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'MinisterialDepartmentTypeIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kodeliste værdi fra DFDG. (Fleksjobtype)', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'FlexJobEmploymentTypeIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Opdateret type', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'ChangeTypeId';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kodeliste værdi fra DFDG. (Planversiontype)', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'PlanVersionTypeId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kodeliste værdi fra DFDG.(Timetilskudssats (kun for lønstilskud og voksenlærlinge))', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'JobOrderPriceHourTypeIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Rådighedsafprøvende', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'AvailabilityProving';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kodeliste værdi fra DFDG. (Aktiveringspulje - Job)', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'JobAllocationTypeIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgers interne identifikation', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'PersonId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Formålskode for virksomhedspraktik', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'PurposeOfCompanyInternshipTypeIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'ny kolonne release 6.3', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'EmploymentGoalAliasIdentifier';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'ny kolonne release 6.3', 
@level0type = N'SCHEMA', @level0name = N'D140-11-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_02_ActivityCompanyItemHistory', 
@level2type = N'COLUMN', @level2name = N'EmploymentGoalConceptUriDa';
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_02_ActivityCompanyItemHistory', 
@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_02_ActivityCompanyItemHistory', 
@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_02_ActivityCompanyItemHistory', 
@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_02_ActivityCompanyItemHistory', 
@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_02_ActivityCompanyItemHistory', 
@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_02_ActivityCompanyItemHistory', 
@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_02_ActivityCompanyItemHistory', 
@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_02_ActivityCompanyItemHistory', 
@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_02_ActivityCompanyItemHistory', 
@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_02_ActivityCompanyItemHistory', 
@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_02_ActivityCompanyItemHistory';
GO

