CREATE TABLE [Skole].[FactKarakter](
  [FactKarakterID] [bigint] NULL,
  [Karakter] [int] NULL,
  [Karaktervaerdi] [int] NULL,
  [KaraktervaerdiVaegtet] [decimal](4,2) NULL,
  [KarakterVaegt] [decimal](4,2) NULL,
  [DimTid] [bigint] NULL,
  [DimAlder] [bigint] NULL,
  [DimBorger] [bigint] NULL,
  [DimLandStatsborgerskab] [bigint] NULL,
  [DimGeografiBopael] [bigint] NULL,
  [KommunenummerBopaelskommune] [int] NULL,
  [DimKommuneBopaelkommune] [bigint] NULL,
  [KommunenummerBetalingkommune] [int] NULL,
  [DimKommuneBetalingkommune] [bigint] NULL,
  [KommunenummerSkoleejerkommune] [int] NULL,
  [DimKommuneSkoleejerkommune] [bigint] NULL,
  [KommunenummerTilhoersforhold] [int] NULL,
  [DimKommuneTilhoersforhold] [bigint] NULL,
  [DimFag] [bigint] NULL,
  [DimFagdisciplin] [bigint] NULL,
  [DimBedoemmelsesform] [bigint] NULL,
  [DimProeveniveau] [bigint] NULL,
  [DimProeveform] [bigint] NULL,
  [DimKaraktergruppering] [bigint] NULL,
  [DimKarakteraarsag] [bigint] NULL,
  [DimElevtype] [bigint] NULL,
  [DimAlderssvarende] [bigint] NULL,
  [DimKlassetrinPersonligt] [bigint] NULL,
  [DimKlassetrin] [bigint] NULL,
  [DimKlassetype] [bigint] NULL,
  [DimKlasse] [bigint] NULL,
  [DimInstitutionstype] [bigint] NULL,
  [DimInstitution] [bigint] NULL,
  [DimJaNejDanskSomAndetsprog] [bigint] NULL,
  [DimJaNejFuldAfgangsproeve] [bigint] NULL,
  [DimJaNejMindstToIDanskOgMat] [bigint] NULL,
  [DimJaNejMindstFireBundneProevefag] [bigint] NULL,
  [DimJaNejHarKarakter] [bigint] NULL,
  [DimJaNejHarProevekarakter] [bigint] NULL,
  [DimJaNejHarStandpunktskarakter] [bigint] NULL,
  [DimJaNejHarKarakterIAlleBundneProevefag] [bigint] NULL,
  [DimJaNejHarKarakterIAlleFagIDansk] [bigint] NULL,
  [DimJaNejHarKarakterIAlleFagIMat] [bigint] NULL,
  [Skoledistrikt] [int] NULL,
  [UnikPersonFag] [varchar](20) 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
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE UNIQUE CLUSTERED INDEX [IDX_CL_Skole_FactKarakter]
On [Skole].[FactKarakter] ([SYS_KommuneId], [SYS_RowID])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder oplysninger om karakter for gennemførte prøver (borger, elev og klasse)', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Surrogatnøgle', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'FactKarakterID';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Karaktertæller', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'Karakter';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver karakteren', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'Karaktervaerdi';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Er produktet af karaktervaerdien og karatervægten. Er null, hvis prøveformen ikke har en vaegt', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'KaraktervaerdiVaegtet';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver karaktens vægt', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'KarakterVaegt';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tid for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimTid';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Alder for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimAlder';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Borger for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimBorger';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Statsborgerskab for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimLandStatsborgerskab';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Bopael for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimGeografiBopael';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Bopaelskommune for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'KommunenummerBopaelskommune';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Bopaelkommune for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimKommuneBopaelkommune';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Betalingkommune for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'KommunenummerBetalingkommune';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Betalingkommune for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimKommuneBetalingkommune';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Skoleejerkommune for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'KommunenummerSkoleejerkommune';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Skoleejerkommune for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimKommuneSkoleejerkommune';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tilhoersforhold for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'KommunenummerTilhoersforhold';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Tilhoersforhold for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimKommuneTilhoersforhold';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fag for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimFag';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fagdisciplin for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimFagdisciplin';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Bedoemmelsesform for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimBedoemmelsesform';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Proeveniveau for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimProeveniveau';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Proeveform for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimProeveform';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Karaktergruppering for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimKaraktergruppering';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Karakteraarsag for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimKarakteraarsag';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Elevtype for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimElevtype';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Alderssvarende for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimAlderssvarende';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Personligt for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimKlassetrinPersonligt';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Klassetrin for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimKlassetrin';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Klassetype for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimKlassetype';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Klasse for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimKlasse';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Institutionstype for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimInstitutionstype';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Institution for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimInstitution';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Andetsprog for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimJaNejDanskSomAndetsprog';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Afgangsproeve for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimJaNejFuldAfgangsproeve';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Mat for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimJaNejMindstToIDanskOgMat';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Proevefag for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimJaNejMindstFireBundneProevefag';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Karakter for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimJaNejHarKarakter';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Proevekarakter for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimJaNejHarProevekarakter';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Standpunktskarakter for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimJaNejHarStandpunktskarakter';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Proevefag for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimJaNejHarKarakterIAlleBundneProevefag';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'IDansk for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimJaNejHarKarakterIAlleFagIDansk';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'IMat for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'DimJaNejHarKarakterIAlleFagIMat';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Skoledistrikt for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'Skoledistrikt';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Fag for karaktern', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'UnikPersonFag';
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'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@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'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@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'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@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'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter', 
@level2type = N'COLUMN', @level2name = N'SYS_ExtractDate';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'skole', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'FactKarakter';
GO

