CREATE TABLE [DFDG].[FactVisitation](
  [FactVisitationID] [bigint] NULL,
  [DimBorger] [bigint] NULL,
  [DimOrganisation] [bigint] NULL,
  [DimTidStart] [bigint] NULL,
  [DimTidSlut] [bigint] NULL,
  [DimKommune] [bigint] NULL,
  [DimVisitation] [bigint] NULL,
  [SYS_KommuneId] [int] NULL,
  [SYS_BatchDate] [datetime2](3) NULL,
  [SYS_RowID] [bigint] identity(1,1) NOT NULL,
  [SYS_ExtractDate] [datetime2](3) NULL,
  [SYS_ExecutionId] [bigint] NULL
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE UNIQUE CLUSTERED INDEX [IDX_CL_DFDG_FactVisitation]
On [DFDG].[FactVisitation] ([SYS_KommuneId], [SYS_RowID])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Facttabel indeholdende visitationsforløb', 
@level0type = N'SCHEMA', @level0name = N'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Id', 
@level0type = N'SCHEMA', @level0name = N'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation', 
@level2type = N'COLUMN', @level2name = N'FactVisitationID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver borgeren', 
@level0type = N'SCHEMA', @level0name = N'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation', 
@level2type = N'COLUMN', @level2name = N'DimBorger';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Koden som identificerer organisationen, der har registreret visitationen.', 
@level0type = N'SCHEMA', @level0name = N'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation', 
@level2type = N'COLUMN', @level2name = N'DimOrganisation';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver startdatoen for visiteringen.', 
@level0type = N'SCHEMA', @level0name = N'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation', 
@level2type = N'COLUMN', @level2name = N'DimTidStart';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver slutdatoen for visiteringen.', 
@level0type = N'SCHEMA', @level0name = N'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation', 
@level2type = N'COLUMN', @level2name = N'DimTidSlut';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver kommunen.', 
@level0type = N'SCHEMA', @level0name = N'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation', 
@level2type = N'COLUMN', @level2name = N'DimKommune';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver visitationen.', 
@level0type = N'SCHEMA', @level0name = N'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation', 
@level2type = N'COLUMN', @level2name = N'DimVisitation';
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'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation', 
@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'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation', 
@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'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation', 
@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'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation', 
@level2type = N'COLUMN', @level2name = N'SYS_ExtractDate';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'dfdg', 
@level0type = N'SCHEMA', @level0name = N'DFDG', 
@level1type = N'TABLE',  @level1name = N'FactVisitation';
GO

