CREATE TABLE [FSIII].[FactFSIIIPlanlagtIndsats](
  [FactFSIIIPlanlagtIndsatsID] [bigint] identity(1,1) NOT NULL,
  [DimTid] [bigint] NULL,
  [DimBorger] [bigint] NULL,
  [DimAlder] [bigint] NULL,
  [DimKommune] [bigint] NULL,
  [DimFSIIIIndsats] [bigint] NULL,
  [DimFSIIITilstandType] [bigint] NULL,
  [DimTidPlanlagtIndsatsStart] [bigint] NULL,
  [DimTidPlanlagtIndsatsSlut] [bigint] NULL,
  [DimJaNejOprettetPlanlagtIndsats] [bigint] NULL,
  [DimJaNejAfsluttetPlanlagtIndsats] [bigint] NULL,
  [DimFSIIIPlanlagtIndsatsStatus] [bigint] NULL,
  [Løbetid] [int] NULL,
  [DimFSIIILøbeTidInterval] [bigint] NULL,
  [TilstandNaturligNøgle] [varchar](64) COLLATE Norwegian_100_CI_AS NULL,
  [SYS_KommuneId] [int] NULL,
  [SYS_BatchDate] [datetime2](3) NULL,
  [SYS_RowID] AS ([FactFSIIIPlanlagtIndsatsID]) ,
  [SYS_ExtractDate] [datetime2](3) NULL,
  [SYS_ExecutionId] [bigint] NULL
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE UNIQUE CLUSTERED INDEX [IDX_CL_FSIII_FactFSIIIPlanlagtIndsats]
On [FSIII].[FactFSIIIPlanlagtIndsats] ([SYS_KommuneId], [FactFSIIIPlanlagtIndsatsID])
--with (data_compression = page)
ON [PRIMARY]
GO

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

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

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

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

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

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'FSIIIIndsats for indsatsn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIIPlanlagtIndsats', 
@level2type = N'COLUMN', @level2name = N'DimFSIIIIndsats';
GO

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

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Slut for indsatsn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIIPlanlagtIndsats', 
@level2type = N'COLUMN', @level2name = N'DimTidPlanlagtIndsatsSlut';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indsats for indsatsn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIIPlanlagtIndsats', 
@level2type = N'COLUMN', @level2name = N'DimJaNejOprettetPlanlagtIndsats';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indsats for indsatsn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIIPlanlagtIndsats', 
@level2type = N'COLUMN', @level2name = N'DimJaNejAfsluttetPlanlagtIndsats';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Løbetid for indsatsn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIIPlanlagtIndsats', 
@level2type = N'COLUMN', @level2name = N'Løbetid';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Interval for indsatsn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIIPlanlagtIndsats', 
@level2type = N'COLUMN', @level2name = N'DimFSIIILøbeTidInterval';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Nøgle for indsatsn', 
@level0type = N'SCHEMA', @level0name = N'FSIII', 
@level1type = N'TABLE',  @level1name = N'FactFSIIIPlanlagtIndsats', 
@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'FactFSIIIPlanlagtIndsats', 
@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'FactFSIIIPlanlagtIndsats', 
@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'FactFSIIIPlanlagtIndsats', 
@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'FactFSIIIPlanlagtIndsats', 
@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'FactFSIIIPlanlagtIndsats', 
@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'FactFSIIIPlanlagtIndsats';
GO

