CREATE TABLE [DREAM].[DimDreamBorger](
  [DimDreamBorgerID] [bigint] identity(1,1) NOT NULL,
  [PMarkørID] [bigint] NULL,
  [Personnummer] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Køn] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [Civilstand] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [Herkomst] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [Statsborgerskab] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [DagpengeModtager] [bit] NULL,
  [Kontanthjælpsmodtager] [bit] NULL,
  [SygedagpengeModtager] [bit] NULL,
  [FørtidspensionModtager] [bit] NULL,
  [NulstillendeSamtale1] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale2] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale3] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale4] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale5] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale6] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale7] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale8] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale9] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale10] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale11] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale12] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale13] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale14] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale15] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale16] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale17] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale18] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale19] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale20] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale21] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale22] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale23] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [NulstillendeSamtale24] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [IndplaceringDagpengeperiode] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [IndplaceringDagpengeperiode1] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [IndplaceringDagpengeperiode2] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [IndplaceringDagpengeperiode3] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [IndplaceringDagpengeperiode4] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [IntegrationsprogramStartdato] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [IntegrationsprogramSlutdato] [varchar](12) COLLATE Norwegian_100_CI_AS NULL,
  [SYS_KommuneId] [int] NULL,
  [SYS_BatchDate] [datetime2](3) NULL,
  [SYS_RowID] AS ([DimDreamBorgerID]) ,
  [SYS_ExtractDate] [datetime2](3) NULL,
  [SYS_ExecutionId] [bigint] NULL,
  CONSTRAINT PK_DimDreamBorger PRIMARY KEY CLUSTERED (DimDreamBorgerID)
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE INDEX [IDX_Kommune_DREAM_DimDreamBorger]
On [DREAM].[DimDreamBorger] ([SYS_KommuneId], [SYS_ExecutionId])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder attributter på borgere i DREAM', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'ID', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'DimDreamBorgerID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'PMarkoerID er en tællemekanisme til at tælle unikkepersoner I benchmark', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'PMarkørID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens personnummer', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'Personnummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens køn jf. seneste modtagne datafil', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'Køn';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens civilstand jf. seneste modtagne datafil', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'Civilstand';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens herkomst jf. seneste modtagne datafil', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'Herkomst';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens statsborgerskab jf. seneste modtagne datafil', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'Statsborgerskab';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angivelse om borgeren har været dagpengemodtager jf. seneste modtagne datafil', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'DagpengeModtager';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angivelse om borgeren har været kontanthjælpsmodtager jf. seneste modtagne datafil', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'Kontanthjælpsmodtager';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angivelse om borgeren har været sygedagpengemodtager jf. seneste modtagne datafil', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'SygedagpengeModtager';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angivelse om borgeren har været modtager af førtidspension jf. seneste modtagne datafil', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'FørtidspensionModtager';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 2. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale2';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 3. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale3';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 4. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale4';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 5. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale5';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 6. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale6';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 7. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale7';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 8. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale8';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 9. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale9';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 10. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale10';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 11. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale11';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 12. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale12';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 13. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale13';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 14. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale14';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 15. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale15';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 16. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale16';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 17. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale17';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 18. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale18';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 19. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale19';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 20. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale20';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 21. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale21';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 22. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale22';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 23. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale23';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 24. seneste nulstillende samtale', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'NulstillendeSamtale24';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerensseneste indplacering i dagpengeperiode', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'IndplaceringDagpengeperiode';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 2. seneste indplacering i dagpengeperiode', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'IndplaceringDagpengeperiode1';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 3. seneste indplacering i dagpengeperiode', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'IndplaceringDagpengeperiode2';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 4. seneste indplacering i dagpengeperiode', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'IndplaceringDagpengeperiode3';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens 5. seneste indplacering i dagpengeperiode', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'IndplaceringDagpengeperiode4';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens integrationsprogram startdato', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'IntegrationsprogramStartdato';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borgerens integrationsprogram slutdato', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'IntegrationsprogramSlutdato';
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'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@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'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@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'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@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'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'SYS_ExtractDate';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'SysExecutionId', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger', 
@level2type = N'COLUMN', @level2name = N'SYS_ExecutionId';
GO

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'dream', 
@level0type = N'SCHEMA', @level0name = N'DREAM', 
@level1type = N'TABLE',  @level1name = N'DimDreamBorger';
GO

