CREATE TABLE [Generel].[DimTidMåned](
  [DimTidMånedID] [bigint] NOT NULL,
  [MånedNøgle] [int] NULL,
  [MånedNummer] [int] NULL,
  [MånedNavn] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [MånedNavnKort] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [MånedIÅr] [int] NULL,
  [MånedIÅrNavn] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [MånedIÅrSortering] [varchar](3) COLLATE Norwegian_100_CI_AS NULL,
  [PrimoMåned] [datetime2](3) NULL,
  [UltimoMåned] [datetime2](3) NULL,
  [KvartalNummer] [int] NULL,
  [KvartalNavn] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [KvartalIÅr] [int] NULL,
  [KvartalIÅrNavn] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [PrimoKvartal] [datetime2](3) NULL,
  [UItimoKvartal] [datetime2](3) NULL,
  [HalvårNummer] [int] NULL,
  [HalvårNavn] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [HalvårIÅr] [int] NULL,
  [HalvårIÅrNavn] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [PrimoHalvår] [datetime2](3) NULL,
  [UltimoHalvår] [datetime2](3) NULL,
  [År] [int] NULL,
  [PrimoÅr] [datetime2](3) NULL,
  [UltimoÅr] [datetime2](3) 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_DimTidMåned PRIMARY KEY CLUSTERED (DimTidMånedID)
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE INDEX [IDX_Kommune_Generel_DimTidMåned]
On [Generel].[DimTidMåned] ([SYS_KommuneId], [SYS_ExecutionId])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tidsdimension som bruges til at koble til maanedsnummer', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'DimTidMånedID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'MånedNøgle';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'MånedNummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'MånedNavn';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'MånedNavnKort';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'MånedIÅr';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'MånedIÅrNavn';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'MånedIÅrSortering';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'PrimoMåned';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'UltimoMåned';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'KvartalNummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'KvartalNavn';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'KvartalIÅr';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'KvartalIÅrNavn';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'PrimoKvartal';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'UItimoKvartal';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'HalvårNummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'HalvårNavn';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'HalvårIÅr';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'HalvårIÅrNavn';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'PrimoHalvår';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'UltimoHalvår';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'År';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'PrimoÅr';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'UltimoÅr';
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'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@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'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@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'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@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'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned', 
@level2type = N'COLUMN', @level2name = N'SYS_ExtractDate';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'generel', 
@level0type = N'SCHEMA', @level0name = N'Generel', 
@level1type = N'TABLE',  @level1name = N'DimTidMåned';
GO

