CREATE TABLE [ØkonomiBorgerAggrBenchmark].[FactPrimopostAggr](
  [Å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,
  [DimTid] [bigint] NULL,
  [DimAutoriseretKontoplan] [bigint] NULL,
  [DimKommune] [int] 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_ØkonomiBorgerAggrBenchmark_FactPrimopostAggr]
On [ØkonomiBorgerAggrBenchmark].[FactPrimopostAggr] ([SYS_KommuneId], [SYS_RowID])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder aggregeringer af FactPrimoposter', 
@level0type = N'SCHEMA', @level0name = N'ØkonomiBorgerAggrBenchmark', 
@level1type = N'TABLE',  @level1name = N'FactPrimopostAggr';
GO

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

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

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

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

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

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

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

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

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

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

