CREATE TABLE [Skole].[DimInstitution](
  [DimInstitutionID] [bigint] NOT NULL,
  [Institutionsnummer] [int] NULL,
  [HovedskoleInstitutionsnummer] [int] NULL,
  [Institutionsnavn] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [Ejerkode] [int] NULL,
  [KommunenummerSkoleejer] [int] NULL,
  [KommunenummerBeliggenhed] [int] NULL,
  [NedlagtMaaned] [datetime2](3) NULL,
  [InstitutionstypeID] [int] NULL,
  [Produktionssystem] [varchar](10) 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_DimInstitution PRIMARY KEY CLUSTERED (DimInstitutionID)
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE INDEX [IDX_Kommune_Skole_DimInstitution]
On [Skole].[DimInstitution] ([SYS_KommuneId], [SYS_ExecutionId])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder oplysninger om Skoler (skoler med skoletyper)', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'DimInstitution';
GO

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

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

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

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

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

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

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Måneden hvor institutionen blev nedlagt. Angives 9999-12-31, hvis institutionen er aktiv.', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'DimInstitution', 
@level2type = N'COLUMN', @level2name = N'NedlagtMaaned';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Angiver hvilket produktionssystem institutionen kommer fra.', 
@level0type = N'SCHEMA', @level0name = N'Skole', 
@level1type = N'TABLE',  @level1name = N'DimInstitution', 
@level2type = N'COLUMN', @level2name = N'Produktionssystem';
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'DimInstitution', 
@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'DimInstitution', 
@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'DimInstitution', 
@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'DimInstitution', 
@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'DimInstitution', 
@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'DimInstitution';
GO

