CREATE TABLE [KY].[DimKYYdelsestype](
  [DimKYYdelsestypeID] [bigint] NOT NULL,
  [YdelsesType] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [YdelsesartTekst] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [YdelsestypeTitel] [varchar](100) COLLATE Norwegian_100_CI_AS NULL,
  [YdelsestypeBeskrivelse] [varchar](500) COLLATE Norwegian_100_CI_AS NULL,
  [YRTekst] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [RetskildeTekst] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [KleNummer] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [IMTekst] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [UdbetalingsparagrafTekst] [varchar](50) COLLATE Norwegian_100_CI_AS NULL,
  [SkattepligtTekst] [varchar](50) 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_DimKYYdelsestype PRIMARY KEY CLUSTERED (DimKYYdelsestypeID)
) 
ON [PRIMARY]
--with (data_compression = page)
GO

CREATE INDEX [IDX_Kommune_KY_DimKYYdelsestype]
On [KY].[DimKYYdelsestype] ([SYS_KommuneId], [SYS_ExecutionId])
--with (data_compression = page)
ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'Indeholder oplysinger på Ydelsestyper', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@level2type = N'COLUMN', @level2name = N'YdelsesType';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@level2type = N'COLUMN', @level2name = N'YdelsesartTekst';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@level2type = N'COLUMN', @level2name = N'YdelsestypeTitel';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@level2type = N'COLUMN', @level2name = N'YdelsestypeBeskrivelse';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@level2type = N'COLUMN', @level2name = N'YRTekst';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@level2type = N'COLUMN', @level2name = N'RetskildeTekst';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@level2type = N'COLUMN', @level2name = N'KleNummer';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@level2type = N'COLUMN', @level2name = N'IMTekst';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@level2type = N'COLUMN', @level2name = N'UdbetalingsparagrafTekst';
GO

EXEC sys.sp_addextendedproperty 
@name = N'MS_Description', 
@value = N'', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@level2type = N'COLUMN', @level2name = N'SkattepligtTekst';
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'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@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'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@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'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@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'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype', 
@level2type = N'COLUMN', @level2name = N'SYS_ExtractDate';
GO

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

EXEC sys.sp_addextendedproperty 
@name = N'DataArea', 
@value = N'ky', 
@level0type = N'SCHEMA', @level0name = N'KY', 
@level1type = N'TABLE',  @level1name = N'DimKYYdelsestype';
GO

