CREATE TABLE [Økonomi].[FactPrimopost](
  [År] [int] NULL,
  [Måned] [int] NULL,
  [Dranst] [int] NULL,
  [Funktion] [varchar](20) COLLATE Norwegian_100_CI_AS NULL,
  [Beløb] [decimal](15,2) NULL,
  [Kilde] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [Leverandør] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [DimTid] [bigint] NULL,
  [Kommunenummer] [int] NULL,
  [DimKommune] [int] NULL,
  [DimAutoriseretKontoplan] [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_Økonomi_FactPrimopost]
On [Økonomi].[FactPrimopost] ([SYS_KommuneId], [SYS_RowID])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder information om primoposter', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@level2type = N'COLUMN', @level2name = N'År';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@level2type = N'COLUMN', @level2name = N'Dranst';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@level2type = N'COLUMN', @level2name = N'Funktion';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@level2type = N'COLUMN', @level2name = N'Beløb';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@level2type = N'COLUMN', @level2name = N'Kilde';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@level2type = N'COLUMN', @level2name = N'Leverandør';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fremmednøgle til DimTid tabellen', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@level2type = N'COLUMN', @level2name = N'DimTid';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@level2type = N'COLUMN', @level2name = N'Kommunenummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fremmednøgle til DimKommune tabellen', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@level2type = N'COLUMN', @level2name = N'DimKommune';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fremmednøgle til DimAutoriseretKontoplan tabellen', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@level2type = N'COLUMN', @level2name = N'DimAutoriseretKontoplan';
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'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@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'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@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'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@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'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost', 
@level2type = N'COLUMN', @level2name = N'SYS_ExtractDate';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'oekonomi', 
@level0type = N'SCHEMA', @level0name = N'Økonomi', 
@level1type = N'TABLE',  @level1name = N'FactPrimopost';
GO

