﻿GO
SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;

SET NUMERIC_ROUNDABORT OFF;

GO
PRINT N'Dropping [dbo].[FK_4026116_4026121]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] DROP CONSTRAINT [FK_4026116_4026121];


GO
PRINT N'Dropping [dbo].[FK_4026116_4026122]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] DROP CONSTRAINT [FK_4026116_4026122];


GO
PRINT N'Dropping [dbo].[FK_4026116_4026343]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] DROP CONSTRAINT [FK_4026116_4026343];


GO
PRINT N'Dropping [dbo].[FK_4026116_4026352]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] DROP CONSTRAINT [FK_4026116_4026352];


GO
PRINT N'Dropping [dbo].[FK_4026116_4026365]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] DROP CONSTRAINT [FK_4026116_4026365];


GO
PRINT N'Dropping [dbo].[FK_4026116_4027631]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] DROP CONSTRAINT [FK_4026116_4027631];


GO
PRINT N'Dropping [dbo].[FK_4026116_4027635]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] DROP CONSTRAINT [FK_4026116_4027635];


GO
PRINT N'Dropping [dbo].[FK_4026125_4026124]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] DROP CONSTRAINT [FK_4026125_4026124];


GO
PRINT N'Dropping [dbo].[FK_4026129_4026127]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] DROP CONSTRAINT [FK_4026129_4026127];


GO
PRINT N'Dropping [dbo].[FK_402611602_402611600]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] DROP CONSTRAINT [FK_402611602_402611600];


GO
PRINT N'Dropping [dbo].[FK_402611605_402611603]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] DROP CONSTRAINT [FK_402611605_402611603];


GO
PRINT N'Dropping [dbo].[FK_4025763_4025762]...';


GO
ALTER TABLE [dbo].[T_NAPLOELLENORZES] DROP CONSTRAINT [FK_4025763_4025762];


GO
PRINT N'Dropping [dbo].[FK_T_4025296_4025338]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_T_4025296_4025338];


GO
PRINT N'Dropping [dbo].[FK_4025320_4025319]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_4025320_4025319];


GO
PRINT N'Dropping [dbo].[FK_4025323_4025322]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_4025323_4025322];


GO
PRINT N'Dropping [dbo].[FK_4025421_4025419]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_4025421_4025419];


GO
PRINT N'Dropping [dbo].[FK_402529402_402529400]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_402529402_402529400];


GO
PRINT N'Dropping [dbo].[FK_402529405_402529403]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_402529405_402529403];


GO
PRINT N'Dropping [dbo].[FK_4025294_4025295]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_4025294_4025295];


GO
PRINT N'Dropping [dbo].[FK_4025294_4027544]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_4025294_4027544];


GO
PRINT N'Dropping [dbo].[FK_4025294_4027545]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_4025294_4027545];


GO
PRINT N'Dropping [dbo].[FK_4025294_4027546]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_4025294_4027546];


GO
PRINT N'Dropping [dbo].[FK_4025294_4027547]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_4025294_4027547];


GO
PRINT N'Dropping [dbo].[FK_4025294_4028299]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] DROP CONSTRAINT [FK_4025294_4028299];


GO
PRINT N'Dropping [dbo].[FK_4026206_4026204]...';


GO
ALTER TABLE [dbo].[T_CSOPORT] DROP CONSTRAINT [FK_4026206_4026204];


GO
PRINT N'Dropping [dbo].[FK_4025318_4025316]...';


GO
ALTER TABLE [dbo].[T_CSOPORTOK_OSZTALYOK] DROP CONSTRAINT [FK_4025318_4025316];


GO
PRINT N'Starting rebuilding table [dbo].[T_MUNKAUGYIADATOK]...';


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [dbo].[tmp_ms_xx_T_MUNKAUGYIADATOK] (
    [ID]                            INT             IDENTITY (1, 1) NOT NULL,
    [C_ALKALMAZASKEZDETE]           DATETIME        NULL,
    [C_ALKALMAZASMEGSZUNESE]        DATETIME        NULL,
    [C_KOTELEZOORASZAM]             NUMERIC (10, 2) NOT NULL,
    [C_MUNKAIDOKEDVEZMENYORASZAM]   INT             NULL,
    [C_MUNKAKORTIPUSA]              INT             NULL,
    [C_MUNKAVISZONYTIPUSA]          INT             NULL,
    [C_BETOLTETLENALLASHELY]        CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_MUNKAIDOKEDVEZMENYOKASZOVEG] NVARCHAR (MAX)  NULL,
    [C_TARTOSHELYETTESITES]         CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_PEDAGOGUSSTATUSZA]           INT             NULL,
    [C_BESOROLASIFOKOZAT]           INT             NULL,
    [C_MUNKAIDOKEDVEZMENYOKA]       INT             NULL,
    [C_NYUGDIJAS]                   CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_RESZMUNKAIDOSZAZALEK]        INT             DEFAULT ((100)) NULL,
    [C_FOGLALKOZTATASTIPUS]         INT             NULL,
    [C_VEZETOIORASZAMOK]            INT             NULL,
    [C_UTAZOGYOGYPEDAGOGUS]         CHAR (1)        DEFAULT ('F') NULL,
    [C_CSOKKENTETTMUNKAIDOS]        CHAR (1)        DEFAULT ('F') NULL,
    [C_SZAKERTOMESTERPEDAGOGUS]     CHAR (1)        DEFAULT ('F') NULL,
    [C_SZABADALLASHELY]             CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_ATTANITO]                    CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_ATTANITOMASINTEZMENYNEL]     CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_FELADATELLATASIHELYID]       INT             NULL,
    [C_ALKALMAZOTTID]               INT             NOT NULL,
    [C_INTEZMENYID]                 INT             NOT NULL,
    [C_TANEVID]                     INT             NOT NULL,
    [TOROLT]                        CHAR (1)        DEFAULT ('F') NOT NULL,
    [SERIAL]                        INT             DEFAULT ((0)) NOT NULL,
    [LASTCHANGED]                   DATETIME        DEFAULT (getdate()) NOT NULL,
    [CREATED]                       DATETIME        DEFAULT (getdate()) NOT NULL,
    [MODIFIER]                      INT             NULL,
    [CREATOR]                       INT             NULL,
    [ELOZOTANEVIREKORDID]           INT             NULL,
    [NNID]                          INT             NULL,
    CONSTRAINT [tmp_ms_xx_constraint_PK_T_40261161] PRIMARY KEY CLUSTERED ([ID] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [dbo].[T_MUNKAUGYIADATOK])
    BEGIN
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_MUNKAUGYIADATOK] ON;
        INSERT INTO [dbo].[tmp_ms_xx_T_MUNKAUGYIADATOK] ([ID], [C_ALKALMAZASKEZDETE], [C_ALKALMAZASMEGSZUNESE], [C_KOTELEZOORASZAM], [C_MUNKAIDOKEDVEZMENYORASZAM], [C_MUNKAKORTIPUSA], [C_MUNKAVISZONYTIPUSA], [C_BETOLTETLENALLASHELY], [C_MUNKAIDOKEDVEZMENYOKASZOVEG], [C_TARTOSHELYETTESITES], [C_PEDAGOGUSSTATUSZA], [C_BESOROLASIFOKOZAT], [C_MUNKAIDOKEDVEZMENYOKA], [C_NYUGDIJAS], [C_RESZMUNKAIDOSZAZALEK], [C_FOGLALKOZTATASTIPUS], [C_VEZETOIORASZAMOK], [C_UTAZOGYOGYPEDAGOGUS], [C_CSOKKENTETTMUNKAIDOS], [C_SZAKERTOMESTERPEDAGOGUS], [C_SZABADALLASHELY], [C_FELADATELLATASIHELYID], [C_ALKALMAZOTTID], [C_INTEZMENYID], [C_TANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR], [ELOZOTANEVIREKORDID], [NNID])
        SELECT   [ID],
                 [C_ALKALMAZASKEZDETE],
                 [C_ALKALMAZASMEGSZUNESE],
                 [C_KOTELEZOORASZAM],
                 [C_MUNKAIDOKEDVEZMENYORASZAM],
                 [C_MUNKAKORTIPUSA],
                 [C_MUNKAVISZONYTIPUSA],
                 [C_BETOLTETLENALLASHELY],
                 [C_MUNKAIDOKEDVEZMENYOKASZOVEG],
                 [C_TARTOSHELYETTESITES],
                 [C_PEDAGOGUSSTATUSZA],
                 [C_BESOROLASIFOKOZAT],
                 [C_MUNKAIDOKEDVEZMENYOKA],
                 [C_NYUGDIJAS],
                 [C_RESZMUNKAIDOSZAZALEK],
                 [C_FOGLALKOZTATASTIPUS],
                 [C_VEZETOIORASZAMOK],
                 [C_UTAZOGYOGYPEDAGOGUS],
                 [C_CSOKKENTETTMUNKAIDOS],
                 [C_SZAKERTOMESTERPEDAGOGUS],
                 [C_SZABADALLASHELY],
                 [C_FELADATELLATASIHELYID],
                 [C_ALKALMAZOTTID],
                 [C_INTEZMENYID],
                 [C_TANEVID],
                 [TOROLT],
                 [SERIAL],
                 [LASTCHANGED],
                 [CREATED],
                 [MODIFIER],
                 [CREATOR],
                 [ELOZOTANEVIREKORDID],
                 [NNID]
        FROM     [dbo].[T_MUNKAUGYIADATOK]
        ORDER BY [ID] ASC;
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_MUNKAUGYIADATOK] OFF;
    END

DROP TABLE [dbo].[T_MUNKAUGYIADATOK];

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_T_MUNKAUGYIADATOK]', N'T_MUNKAUGYIADATOK';

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_constraint_PK_T_40261161]', N'PK_T_4026116', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Creating [dbo].[T_MUNKAUGYIADATOK].[I_T_4026116_4026121]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026116_4026121]
    ON [dbo].[T_MUNKAUGYIADATOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_MUNKAKORTIPUSA] ASC);


GO
PRINT N'Creating [dbo].[T_MUNKAUGYIADATOK].[I_T_4026116_4026122]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026116_4026122]
    ON [dbo].[T_MUNKAUGYIADATOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_MUNKAVISZONYTIPUSA] ASC);


GO
PRINT N'Creating [dbo].[T_MUNKAUGYIADATOK].[I_T_4026116_4026343]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026116_4026343]
    ON [dbo].[T_MUNKAUGYIADATOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_PEDAGOGUSSTATUSZA] ASC);


GO
PRINT N'Creating [dbo].[T_MUNKAUGYIADATOK].[I_T_4026116_4026352]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026116_4026352]
    ON [dbo].[T_MUNKAUGYIADATOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_BESOROLASIFOKOZAT] ASC);


GO
PRINT N'Creating [dbo].[T_MUNKAUGYIADATOK].[I_T_4026116_4026365]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026116_4026365]
    ON [dbo].[T_MUNKAUGYIADATOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_MUNKAIDOKEDVEZMENYOKA] ASC);


GO
PRINT N'Creating [dbo].[T_MUNKAUGYIADATOK].[I_T_4026116_4027631]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026116_4027631]
    ON [dbo].[T_MUNKAUGYIADATOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_FOGLALKOZTATASTIPUS] ASC);


GO
PRINT N'Creating [dbo].[T_MUNKAUGYIADATOK].[I_T_4026116_4027635]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026116_4027635]
    ON [dbo].[T_MUNKAUGYIADATOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_VEZETOIORASZAMOK] ASC);


GO
PRINT N'Creating [dbo].[T_MUNKAUGYIADATOK].[I_T_4026125_4026124]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026125_4026124]
    ON [dbo].[T_MUNKAUGYIADATOK]([C_FELADATELLATASIHELYID] ASC);


GO
PRINT N'Creating [dbo].[T_MUNKAUGYIADATOK].[I_T_4026129_4026127]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026129_4026127]
    ON [dbo].[T_MUNKAUGYIADATOK]([C_ALKALMAZOTTID] ASC);


GO
PRINT N'Creating [dbo].[T_MUNKAUGYIADATOK].[I_T_402611602_402611600]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402611602_402611600]
    ON [dbo].[T_MUNKAUGYIADATOK]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_MUNKAUGYIADATOK].[I_T_402611605_402611603]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402611605_402611603]
    ON [dbo].[T_MUNKAUGYIADATOK]([C_TANEVID] ASC);


GO
PRINT N'Starting rebuilding table [dbo].[T_OSZTALY]...';


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [dbo].[tmp_ms_xx_T_OSZTALY] (
    [ID]                          INT             NOT NULL,
    [C_KEPZESIFORMA]              INT             NOT NULL,
    [C_OSZTALYNAPLOLEIRASA]       NVARCHAR (MAX)  NULL,
    [C_OSZTALYNAPLOMEGNYITASA]    DATETIME        NULL,
    [C_OSZTALYNAPLOZARASA]        DATETIME        NULL,
    [C_AGAZAT]                    INT             NULL,
    [C_RESZSZAKKEPESITES]         INT             NULL,
    [C_SZAKKEPESITES]             INT             NULL,
    [C_SZAKMACSOPORT]             INT             NULL,
    [C_TECHNIKAIOSZTALY]          CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_GIMNAZIUMIEVFOLYAMTIPUSID] INT             NULL,
    [C_GYOGYPEDAGOGIAI]           CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_KETTANNYELVU]              CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_LOGOPEDIAI]                CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_NEMZETISEGI]               CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_NYELVIELOKESZITO]          CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_SPORT]                     CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_AJTEHETTSEGGONDOZOPROGRAM] CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_AJPROGRAM]                 CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_VEGYESEVFOLYAMU]           CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_VEGYESSZAKKEPZESU]         CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_SPECIALISJELLEMZO]         NVARCHAR (4000) NULL,
    [C_OSZTALYFONOKID]            INT             NULL,
    [C_OFOHELYETTESID]            INT             NULL,
    [C_TANTERVID]                 INT             NULL,
    [C_ALINTEZMENYID]             INT             NOT NULL,
    [C_ALTANEVID]                 INT             NOT NULL,
    [TOROLT]                      CHAR (1)        DEFAULT ('F') NOT NULL,
    [SERIAL]                      INT             DEFAULT ((0)) NOT NULL,
    [LASTCHANGED]                 DATETIME        DEFAULT (getdate()) NOT NULL,
    [CREATED]                     DATETIME        DEFAULT (getdate()) NOT NULL,
    [MODIFIER]                    INT             NULL,
    [CREATOR]                     INT             NULL,
    [ELOZOTANEVIREKORDID]         INT             NULL,
    [ELOZOTANEVIREKORDIDA]        INT             NULL,
    [NNID]                        INT             NULL,
    CONSTRAINT [tmp_ms_xx_constraint_PK_T_40252941] PRIMARY KEY CLUSTERED ([ID] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [dbo].[T_OSZTALY])
    BEGIN
        INSERT INTO [dbo].[tmp_ms_xx_T_OSZTALY] ([ID], [C_KEPZESIFORMA], [C_OSZTALYNAPLOLEIRASA], [C_OSZTALYNAPLOMEGNYITASA], [C_OSZTALYNAPLOZARASA], [C_AGAZAT], [C_RESZSZAKKEPESITES], [C_SZAKKEPESITES], [C_SZAKMACSOPORT], [C_TECHNIKAIOSZTALY], [C_GIMNAZIUMIEVFOLYAMTIPUSID], [C_GYOGYPEDAGOGIAI], [C_KETTANNYELVU], [C_LOGOPEDIAI], [C_NEMZETISEGI], [C_NYELVIELOKESZITO], [C_SPORT], [C_AJTEHETTSEGGONDOZOPROGRAM], [C_AJPROGRAM], [C_VEGYESEVFOLYAMU], [C_VEGYESSZAKKEPZESU], [C_OSZTALYFONOKID], [C_OFOHELYETTESID], [C_TANTERVID], [C_ALINTEZMENYID], [C_ALTANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR], [ELOZOTANEVIREKORDID], [ELOZOTANEVIREKORDIDA], [NNID])
        SELECT   [ID],
                 [C_KEPZESIFORMA],
                 [C_OSZTALYNAPLOLEIRASA],
                 [C_OSZTALYNAPLOMEGNYITASA],
                 [C_OSZTALYNAPLOZARASA],
                 [C_AGAZAT],
                 [C_RESZSZAKKEPESITES],
                 [C_SZAKKEPESITES],
                 [C_SZAKMACSOPORT],
                 [C_TECHNIKAIOSZTALY],
                 [C_GIMNAZIUMIEVFOLYAMTIPUSID],
                 [C_GYOGYPEDAGOGIAI],
                 [C_KETTANNYELVU],
                 [C_LOGOPEDIAI],
                 [C_NEMZETISEGI],
                 [C_NYELVIELOKESZITO],
                 [C_SPORT],
                 [C_AJTEHETTSEGGONDOZOPROGRAM],
                 [C_AJPROGRAM],
                 [C_VEGYESEVFOLYAMU],
                 [C_VEGYESSZAKKEPZESU],
                 [C_OSZTALYFONOKID],
                 [C_OFOHELYETTESID],
                 [C_TANTERVID],
                 [C_ALINTEZMENYID],
                 [C_ALTANEVID],
                 [TOROLT],
                 [SERIAL],
                 [LASTCHANGED],
                 [CREATED],
                 [MODIFIER],
                 [CREATOR],
                 [ELOZOTANEVIREKORDID],
                 [ELOZOTANEVIREKORDIDA],
                 [NNID]
        FROM     [dbo].[T_OSZTALY]
        ORDER BY [ID] ASC;
    END

DROP TABLE [dbo].[T_OSZTALY];

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_T_OSZTALY]', N'T_OSZTALY';

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_constraint_PK_T_40252941]', N'PK_T_4025294', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Creating [dbo].[T_OSZTALY].[I_T_4025294_4025295]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025294_4025295]
    ON [dbo].[T_OSZTALY]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_KEPZESIFORMA] ASC);


GO
PRINT N'Creating [dbo].[T_OSZTALY].[I_T_4025294_4027544]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025294_4027544]
    ON [dbo].[T_OSZTALY]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_AGAZAT] ASC);


GO
PRINT N'Creating [dbo].[T_OSZTALY].[I_T_4025294_4027545]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025294_4027545]
    ON [dbo].[T_OSZTALY]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_RESZSZAKKEPESITES] ASC);


GO
PRINT N'Creating [dbo].[T_OSZTALY].[I_T_4025294_4027546]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025294_4027546]
    ON [dbo].[T_OSZTALY]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_SZAKKEPESITES] ASC);


GO
PRINT N'Creating [dbo].[T_OSZTALY].[I_T_4025294_4027547]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025294_4027547]
    ON [dbo].[T_OSZTALY]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_SZAKMACSOPORT] ASC);


GO
PRINT N'Creating [dbo].[T_OSZTALY].[I_T_4025294_4028299]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025294_4028299]
    ON [dbo].[T_OSZTALY]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_GIMNAZIUMIEVFOLYAMTIPUSID] ASC);


GO
PRINT N'Creating [dbo].[T_OSZTALY].[I_T_4025320_4025319]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025320_4025319]
    ON [dbo].[T_OSZTALY]([C_OSZTALYFONOKID] ASC);


GO
PRINT N'Creating [dbo].[T_OSZTALY].[I_T_4025323_4025322]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025323_4025322]
    ON [dbo].[T_OSZTALY]([C_OFOHELYETTESID] ASC);


GO
PRINT N'Creating [dbo].[T_OSZTALY].[I_T_4025421_4025419]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025421_4025419]
    ON [dbo].[T_OSZTALY]([C_TANTERVID] ASC);


GO
PRINT N'Creating [dbo].[T_OSZTALY].[I_T_402529402_402529400]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402529402_402529400]
    ON [dbo].[T_OSZTALY]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_OSZTALY].[I_T_402529405_402529403]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402529405_402529403]
    ON [dbo].[T_OSZTALY]([C_ALTANEVID] ASC);


GO
PRINT N'Creating [dbo].[FK_4026116_4026121]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4026116_4026121] FOREIGN KEY ([C_MUNKAKORTIPUSA], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_MUNKAKORTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4026116_4026122]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4026116_4026122] FOREIGN KEY ([C_MUNKAVISZONYTIPUSA], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_MUNKAVISZONYTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4026116_4026343]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4026116_4026343] FOREIGN KEY ([C_PEDAGOGUSSTATUSZA], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_PEDAGOGUSSTATUSZ] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4026116_4026352]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4026116_4026352] FOREIGN KEY ([C_BESOROLASIFOKOZAT], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_BESOROLASIFOKOZATTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4026116_4026365]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4026116_4026365] FOREIGN KEY ([C_MUNKAIDOKEDVEZMENYOKA], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_MUNKAIDOKEDVEZMENYOKA] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4026116_4027631]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4026116_4027631] FOREIGN KEY ([C_FOGLALKOZTATASTIPUS], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_FOGLALKOZTATASTIPUSA] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4026116_4027635]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4026116_4027635] FOREIGN KEY ([C_VEZETOIORASZAMOK], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_VEZETOIORASZAMOKTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4026125_4026124]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4026125_4026124] FOREIGN KEY ([C_FELADATELLATASIHELYID]) REFERENCES [dbo].[T_FELADATELLATASIHELY] ([ID]);


GO
PRINT N'Creating [dbo].[FK_4026129_4026127]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4026129_4026127] FOREIGN KEY ([C_ALKALMAZOTTID]) REFERENCES [dbo].[T_ALKALMAZOTT] ([ID]);


GO
PRINT N'Creating [dbo].[FK_402611602_402611600]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_402611602_402611600] FOREIGN KEY ([C_INTEZMENYID]) REFERENCES [dbo].[T_INTEZMENY] ([ID]);


GO
PRINT N'Creating [dbo].[FK_402611605_402611603]...';


GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_402611605_402611603] FOREIGN KEY ([C_TANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


GO
PRINT N'Creating [dbo].[FK_4025763_4025762]...';


GO
ALTER TABLE [dbo].[T_NAPLOELLENORZES] WITH NOCHECK
    ADD CONSTRAINT [FK_4025763_4025762] FOREIGN KEY ([C_OSZTALYID]) REFERENCES [dbo].[T_OSZTALY] ([ID]);


GO
PRINT N'Creating [dbo].[FK_T_4025296_4025338]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_T_4025296_4025338] FOREIGN KEY ([ID]) REFERENCES [dbo].[T_OSZTALYCSOPORT] ([ID]);


GO
PRINT N'Creating [dbo].[FK_4025320_4025319]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025320_4025319] FOREIGN KEY ([C_OSZTALYFONOKID]) REFERENCES [dbo].[T_ALKALMAZOTT] ([ID]);


GO
PRINT N'Creating [dbo].[FK_4025323_4025322]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025323_4025322] FOREIGN KEY ([C_OFOHELYETTESID]) REFERENCES [dbo].[T_ALKALMAZOTT] ([ID]);


GO
PRINT N'Creating [dbo].[FK_4025421_4025419]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025421_4025419] FOREIGN KEY ([C_TANTERVID]) REFERENCES [dbo].[T_TANTERV] ([ID]);


GO
PRINT N'Creating [dbo].[FK_402529402_402529400]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_402529402_402529400] FOREIGN KEY ([C_ALINTEZMENYID]) REFERENCES [dbo].[T_INTEZMENY] ([ID]);


GO
PRINT N'Creating [dbo].[FK_402529405_402529403]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_402529405_402529403] FOREIGN KEY ([C_ALTANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


GO
PRINT N'Creating [dbo].[FK_4025294_4025295]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025294_4025295] FOREIGN KEY ([C_KEPZESIFORMA], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_TANTERVIJELLEG] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4025294_4027544]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025294_4027544] FOREIGN KEY ([C_AGAZAT], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_AGAZATTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4025294_4027545]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025294_4027545] FOREIGN KEY ([C_RESZSZAKKEPESITES], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_RESZSZAKKEPESITESTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4025294_4027546]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025294_4027546] FOREIGN KEY ([C_SZAKKEPESITES], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_SZAKKEPESITESTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4025294_4027547]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025294_4027547] FOREIGN KEY ([C_SZAKMACSOPORT], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_SZAKMACSOPORTTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4025294_4028299]...';


GO
ALTER TABLE [dbo].[T_OSZTALY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025294_4028299] FOREIGN KEY ([C_GIMNAZIUMIEVFOLYAMTIPUSID], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_GIMNAZIUMIEVFOLYAMTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


GO
PRINT N'Creating [dbo].[FK_4026206_4026204]...';


GO
ALTER TABLE [dbo].[T_CSOPORT] WITH NOCHECK
    ADD CONSTRAINT [FK_4026206_4026204] FOREIGN KEY ([C_OSZTALYBONTASID]) REFERENCES [dbo].[T_OSZTALY] ([ID]);


GO
PRINT N'Creating [dbo].[FK_4025318_4025316]...';


GO
ALTER TABLE [dbo].[T_CSOPORTOK_OSZTALYOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4025318_4025316] FOREIGN KEY ([C_OSZTALYOKID]) REFERENCES [dbo].[T_OSZTALY] ([ID]);



GO
PRINT N'Refreshing [dbo].[T_MUNKAUGYIADATOK_OSSZES]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[T_MUNKAUGYIADATOK_OSSZES]';


GO
PRINT N'Refreshing [dbo].[T_OSZTALY_OSSZES]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[T_OSZTALY_OSSZES]';


GO
PRINT N'Refreshing [dbo].[fnGetDokumentumOsztalyokTanevenkent]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[fnGetDokumentumOsztalyokTanevenkent]';


GO
PRINT N'Refreshing [dbo].[fnGetLemorzsolodottTanulokByFelhely]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[fnGetLemorzsolodottTanulokByFelhely]';


GO
PRINT N'Refreshing [dbo].[fnGetDokumentumErtekelesekOsztalyonkent]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[fnGetDokumentumErtekelesekOsztalyonkent]';


GO
PRINT N'Refreshing [dbo].[fnGetDokumentumTanulokEvesOraszamaiOsztalynkonet]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[fnGetDokumentumTanulokEvesOraszamaiOsztalynkonet]';


GO
PRINT N'Refreshing [dbo].[fnGetKopcsolodoOsztalyCsoportokByDateRange]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[fnGetKopcsolodoOsztalyCsoportokByDateRange]';


GO
PRINT N'Refreshing [dbo].[fnGetTanuloOsztaly]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[fnGetTanuloOsztaly]';


GO
PRINT N'Refreshing [dbo].[fnGetDokumentumErtekelesekMuveszetiOktatasbanOsztalyonkent]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[fnGetDokumentumErtekelesekMuveszetiOktatasbanOsztalyonkent]';


GO
PRINT N'Refreshing [dbo].[sp_Global_GetDatabaseErrors]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_Global_GetDatabaseErrors]';


GO
PRINT N'Checking existing data against newly created constraints';

GO
ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4026116_4026121];

ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4026116_4026122];

ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4026116_4026343];

ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4026116_4026352];

ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4026116_4026365];

ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4026116_4027631];

ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4026116_4027635];

ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4026125_4026124];

ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4026129_4026127];

ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_402611602_402611600];

ALTER TABLE [dbo].[T_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_402611605_402611603];

ALTER TABLE [dbo].[T_NAPLOELLENORZES] WITH CHECK CHECK CONSTRAINT [FK_4025763_4025762];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_T_4025296_4025338];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_4025320_4025319];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_4025323_4025322];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_4025421_4025419];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_402529402_402529400];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_402529405_402529403];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_4025294_4025295];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_4025294_4027544];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_4025294_4027545];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_4025294_4027546];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_4025294_4027547];

ALTER TABLE [dbo].[T_OSZTALY] WITH CHECK CHECK CONSTRAINT [FK_4025294_4028299];

ALTER TABLE [dbo].[T_CSOPORT] WITH CHECK CHECK CONSTRAINT [FK_4026206_4026204];

ALTER TABLE [dbo].[T_CSOPORTOK_OSZTALYOK] WITH CHECK CHECK CONSTRAINT [FK_4025318_4025316];


GO
PRINT N'Update complete.';


GO
--------------------


PRINT '--- intézményi view-k (dbo táblákkal megegyezõ nevû és a tábla_OSSZES nevûek) frissítése ---'

DECLARE  @viewname nvarchar(100), @pureview nvarchar(100)

DECLARE semaviewk CURSOR LOCAL FOR 
  SELECT '['+TABLE_SCHEMA + '].[' + TABLE_NAME + ']', TABLE_NAME
  FROM INFORMATION_SCHEMA.TABLES
  WHERE TABLE_TYPE = 'VIEW' and TABLE_SCHEMA LIKE 'KR[_]%[_]Schema'
  AND TABLE_NAME in ('T_OSZTALY', 'T_OSZTALY_OSSZES'
					,'T_MUNKAUGYIADATOK', 'T_MUNKAUGYIADATOK_OSSZES') -- ha csak néhány VIEW frissült, akkor a gyorsabb futásért ide fel lehet sorolni
  ORDER BY TABLE_SCHEMA, TABLE_NAME

OPEN semaviewk
FETCH NEXT FROM semaviewk INTO @viewname, @pureview

WHILE @@FETCH_STATUS = 0 BEGIN
    PRINT @viewname
    EXEC sp_refreshview @viewname

    FETCH NEXT FROM semaviewk INTO @viewname, @pureview
END             

CLOSE semaviewk
DEALLOCATE semaviewk
GO


--------------------


EXEC dev.sp_Global_GenerateAsyncAuditTriggerAll
GO

EXEC dev.sp_Global_GenerateAsyncAuditProcedureAll
GO

EXEC dev.sp_Global_GenerateAsyncAuditAuditPocessing
GO

ALTER QUEUE auditLog.[AuditQueue]
WITH ACTIVATION
( 
    STATUS = ON,
    PROCEDURE_NAME = auditLog.usp_AuditProcessing,
    MAX_QUEUE_READERS = 10,
    EXECUTE AS 'Kreta_tech_user'
);

GO