CREATE TABLE [DFDG].[DimVisitation](
  [DimVisitationID] [bigint] NOT NULL,
  [Navn] [nvarchar](150) COLLATE Norwegian_100_CI_AS NULL,
  [Beskrivelse] [nvarchar](1000) 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_ExecutionId] [bigint] NULL,
  CONSTRAINT PK_DimVisitation PRIMARY KEY CLUSTERED (DimVisitationID)
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE INDEX [IDX_Kommune_DFDG_DimVisitation]
On [DFDG].[DimVisitation] ([SYS_KommuneId], [SYS_ExecutionId])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Dimensionstabel som indeholder visitationskategori', 
@level0type = N'SCHEMA', @level0name = N'DFDG', 
@level1type = N'TABLE',  @level1name = N'DimVisitation';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Nøgle for dimensionen', 
@level0type = N'SCHEMA', @level0name = N'DFDG', 
@level1type = N'TABLE',  @level1name = N'DimVisitation', 
@level2type = N'COLUMN', @level2name = N'DimVisitationID';
GO

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

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

