CREATE TABLE [FSIII].[FactFSIIITilstand](
  [FactFSIIITilstandID] [bigint] identity(1,1) NOT NULL,
  [DimFSIIITilstandType] [bigint] NULL,
  [DimTid] [bigint] NULL,
  [DimBorger] [bigint] NULL,
  [DimAlder] [bigint] NULL,
  [DimKommune] [bigint] NULL,
  [DimTidTilstandStart] [bigint] NULL,
  [DimJaNejOprettetTilstand] [bigint] NULL,
  [DimFSIIITilstandNiveau] [bigint] NULL,
  [DimFSIIIMålNiveau] [bigint] NULL,
  [DimFSIIIBorgerVurderingUdførelse] [bigint] NULL,
  [DimFSIIIBorgerVurderingBetydning] [bigint] NULL,
  [DimFSIIITilstandStatus] [bigint] NULL,
  [TilstandNaturligNøgle] [varchar](64) COLLATE Norwegian_100_CI_AS NULL,
  [SYS_KommuneId] [int] NULL,
  [SYS_BatchDate] [datetime2](3) NULL,
  [SYS_RowID] AS ([FactFSIIITilstandID]) ,
  [SYS_ExtractDate] [datetime2](3) NULL,
  [SYS_ExecutionId] [bigint] NULL
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE UNIQUE CLUSTERED INDEX [IDX_CL_FSIII_FactFSIIITilstand]
On [FSIII].[FactFSIIITilstand] ([SYS_KommuneId], [FactFSIIITilstandID])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder oplysninger om tildstande', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'ID for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'FactFSIIITilstandID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Type for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimFSIIITilstandType';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tid for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimTid';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borger for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimBorger';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Alder for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimAlder';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Kommune for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimKommune';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Start for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimTidTilstandStart';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tilstand for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimJaNejOprettetTilstand';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Niveau for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimFSIIITilstandNiveau';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Niveau for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimFSIIIMålNiveau';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Udførelse for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimFSIIIBorgerVurderingUdførelse';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Betydning for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimFSIIIBorgerVurderingBetydning';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Status for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'DimFSIIITilstandStatus';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Nøgle for fsiiitilstandn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'TilstandNaturligNøgle';
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'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@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'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@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'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@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'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand', 
@level2type = N'COLUMN', @level2name = N'SYS_ExtractDate';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'sundhed', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIITilstand';
GO

