CREATE TABLE [D001-18-2].[DSAHIST_ZIINST_ATTR](
  [ZIKOM] [varchar](5) COLLATE Norwegian_100_CI_AS NULL,
  [ZIINST] [bigint] NULL,
  [ZIINSTTYP] [int] NULL,
  [ZIINSTNAV] [varchar](30) COLLATE Norwegian_100_CI_AS NULL,
  [ZIPSEUDIS] [int] NULL,
  [ZISELVDIS] [varchar](4) COLLATE Norwegian_100_CI_AS NULL,
  [ZIDISTNR] [int] NULL,
  [ZIKOMNR] [varchar](5) COLLATE Norwegian_100_CI_AS NULL,
  [ZIFREMKOM] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [POSTAL_CD0] [varchar](10) COLLATE Norwegian_100_CI_AS NULL,
  [CITY0] [varchar](35) COLLATE Norwegian_100_CI_AS NULL,
  [ZIOMRINST] [varchar](1) COLLATE Norwegian_100_CI_AS NULL,
  [ZISOCDIST] [varchar](6) COLLATE Norwegian_100_CI_AS NULL,
  [ZISKODIST] [varchar](6) COLLATE Norwegian_100_CI_AS NULL,
  [ZIVALDIST] [varchar](6) COLLATE Norwegian_100_CI_AS NULL,
  [ZIPASORD] [varchar](2) 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([ZIKOM],[ZIINST],[ZIINSTTYP],[ZIINSTNAV],[ZIPSEUDIS],[ZISELVDIS],[ZIDISTNR],[ZIKOMNR],[ZIFREMKOM],[POSTAL_CD0],[CITY0],[ZIOMRINST],[ZISOCDIST],[ZISKODIST],[ZIVALDIST],[ZIPASORD])),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_D001-18-2_DSAHIST_ZIINST_ATTR] On [D001-18-2].[DSAHIST_ZIINST_ATTR] (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'Informationer om daginstitutionen.', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kunde identifikation', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZIKOM';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Institution', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZIINST';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Institutionstype', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZIINSTTYP';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Institutionsnavn', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZIINSTNAV';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Distriktstype', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZIPSEUDIS';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Distrikt', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZISELVDIS';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerservicedistrikt', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZIDISTNR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kommune', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZIKOMNR';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fremmed kommune', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZIFREMKOM';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Postnummer', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'POSTAL_CD0';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'By', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'CITY0';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Områdeinstitution', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZIOMRINST';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Socialdistrikt', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZISOCDIST';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Skoledistrikt', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZISKODIST';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Valgdistrikt', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZIVALDIST';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Pasningsordning', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'ZIPASORD';
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'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@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'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@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'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@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'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@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'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@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'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@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'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@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'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR', 
@level2type = N'COLUMN', @level2name = N'SYS_Checksum';
GO

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

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'dagtilbud', 
@level0type = N'SCHEMA', @level0name = N'D001-18-2', 
@level1type = N'TABLE',  @level1name = N'DSAHIST_ZIINST_ATTR';
GO

