﻿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_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_4025712_4025710]...';


GO
ALTER TABLE [dbo].[T_TANULO_TANULOESEMENY] DROP CONSTRAINT [FK_4025712_4025710];


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


GO
ALTER TABLE [dbo].[T_OSZTALYCSOPORT_TANULOESEMENY] DROP CONSTRAINT [FK_4027557_4027555];


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENY] DROP CONSTRAINT [FK_4025714_4025713];


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENY] DROP CONSTRAINT [FK_4025942_4025941];


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENY] DROP CONSTRAINT [FK_4027536_4027535];


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENY] DROP CONSTRAINT [FK_402569902_402569900];


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENY] DROP CONSTRAINT [FK_402569905_402569903];


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENY] DROP CONSTRAINT [FK_4025699_4025708];


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


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] DROP CONSTRAINT [FK_4027558_4027561];


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


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] DROP CONSTRAINT [FK_4027558_4027563];


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


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] DROP CONSTRAINT [FK_4027558_4027566];


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


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] DROP CONSTRAINT [FK_4027558_4027567];


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


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] DROP CONSTRAINT [FK_4027571_4027569];


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


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] DROP CONSTRAINT [FK_4027574_4027572];


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


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] DROP CONSTRAINT [FK_402755802_402755800];


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


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] DROP CONSTRAINT [FK_402755805_402755803];


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_KEPESITES]                   INT             NULL,
    [C_MUNKAIDOKEDVEZMENYOKA]       INT             NULL,
    [C_NYUGDIJAS]                   CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_ISORAADO]                    CHAR (1)        DEFAULT ('F') 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') NULL,
    [SERIAL]                        INT             NULL,
    [LASTCHANGED]                   DATETIME        DEFAULT (getdate()) NULL,
    [CREATED]                       DATETIME        DEFAULT (getdate()) NULL,
    [MODIFIER]                      INT             NULL,
    [CREATOR]                       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_KEPESITES], [C_MUNKAIDOKEDVEZMENYOKA], [C_NYUGDIJAS], [C_FELADATELLATASIHELYID], [C_ALKALMAZOTTID], [C_INTEZMENYID], [C_TANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR])
        SELECT   [ID],
                 [C_ALKALMAZASKEZDETE],
                 [C_ALKALMAZASMEGSZUNESE],
                 [C_KOTELEZOORASZAM],
                 [C_MUNKAIDOKEDVEZMENYORASZAM],
                 [C_MUNKAKORTIPUSA],
                 [C_MUNKAVISZONYTIPUSA],
                 [C_BETOLTETLENALLASHELY],
                 [C_MUNKAIDOKEDVEZMENYOKASZOVEG],
                 [C_TARTOSHELYETTESITES],
                 [C_PEDAGOGUSSTATUSZA],
                 [C_KEPESITES],
                 [C_MUNKAIDOKEDVEZMENYOKA],
                 [C_NYUGDIJAS],
                 [C_FELADATELLATASIHELYID],
                 [C_ALKALMAZOTTID],
                 [C_INTEZMENYID],
                 [C_TANEVID],
                 [TOROLT],
                 [SERIAL],
                 [LASTCHANGED],
                 [CREATED],
                 [MODIFIER],
                 [CREATOR]
        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_KEPESITES] 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_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_TANULOESEMENY]...';


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [dbo].[tmp_ms_xx_T_TANULOESEMENY] (
    [ID]                    INT            IDENTITY (1, 1) NOT NULL,
    [C_KEZDETE]             DATETIME       NOT NULL,
    [C_MEGJEGYZES]          NVARCHAR (255) NULL,
    [C_TARTALOM]            NVARCHAR (MAX) NOT NULL,
    [C_TIPUS]               INT            NOT NULL,
    [C_TARGY]               NVARCHAR (255) NOT NULL,
    [C_FALIUJSAGMEGJELENES] CHAR (1)       NULL,
    [C_MINDENKINEK]         CHAR (1)       NULL,
    [C_VEGE]                DATETIME       NULL,
    [C_ROGZITESDATUMA]      DATETIME       NOT NULL,
    [C_FELJEGYZOID]         INT            NOT NULL,
    [C_TANTARGYID]          INT            NULL,
    [C_TANITASIORAID]       INT            NULL,
    [C_INTEZMENYID]         INT            NOT NULL,
    [C_TANEVID]             INT            NOT NULL,
    [TOROLT]                CHAR (1)       DEFAULT ('F') NULL,
    [SERIAL]                INT            NULL,
    [LASTCHANGED]           DATETIME       DEFAULT (getdate()) NULL,
    [CREATED]               DATETIME       DEFAULT (getdate()) NULL,
    [MODIFIER]              INT            NULL,
    [CREATOR]               INT            NULL,
    CONSTRAINT [tmp_ms_xx_constraint_PK_T_40256991] PRIMARY KEY CLUSTERED ([ID] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [dbo].[T_TANULOESEMENY])
    BEGIN
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_TANULOESEMENY] ON;
        INSERT INTO [dbo].[tmp_ms_xx_T_TANULOESEMENY] ([ID], [C_KEZDETE], [C_MEGJEGYZES], [C_TARTALOM], [C_TIPUS], [C_TARGY], [C_FALIUJSAGMEGJELENES], [C_MINDENKINEK], [C_VEGE], [C_ROGZITESDATUMA], [C_FELJEGYZOID], [C_TANTARGYID], [C_TANITASIORAID], [C_INTEZMENYID], [C_TANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR])
        SELECT   [ID],
                 [C_KEZDETE],
                 [C_MEGJEGYZES],
                 [C_TARTALOM],
                 [C_TIPUS],
                 [C_TARGY],
                 [C_FALIUJSAGMEGJELENES],
                 [C_MINDENKINEK],
                 [C_VEGE],
				 [C_KEZDETE],
                 [C_FELJEGYZOID],
                 [C_TANTARGYID],
                 [C_TANITASIORAID],
                 [C_INTEZMENYID],
                 [C_TANEVID],
                 [TOROLT],
                 [SERIAL],
                 [LASTCHANGED],
                 [CREATED],
                 [MODIFIER],
                 [CREATOR]
        FROM     [dbo].[T_TANULOESEMENY]
        ORDER BY [ID] ASC;
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_TANULOESEMENY] OFF;
    END

DROP TABLE [dbo].[T_TANULOESEMENY];

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_T_TANULOESEMENY]', N'T_TANULOESEMENY';

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_constraint_PK_T_40256991]', N'PK_T_4025699', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Creating [dbo].[T_TANULOESEMENY].[I_T_4025699_4025708]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025699_4025708]
    ON [dbo].[T_TANULOESEMENY]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_TIPUS] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOESEMENY].[I_T_4025714_4025713]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025714_4025713]
    ON [dbo].[T_TANULOESEMENY]([C_FELJEGYZOID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOESEMENY].[I_T_4025942_4025941]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025942_4025941]
    ON [dbo].[T_TANULOESEMENY]([C_TANTARGYID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOESEMENY].[I_T_4027536_4027535]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4027536_4027535]
    ON [dbo].[T_TANULOESEMENY]([C_TANITASIORAID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOESEMENY].[I_T_402569902_402569900]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402569902_402569900]
    ON [dbo].[T_TANULOESEMENY]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOESEMENY].[I_T_402569905_402569903]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402569905_402569903]
    ON [dbo].[T_TANULOESEMENY]([C_TANEVID] ASC);


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


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [dbo].[tmp_ms_xx_T_TOVABBIMUNKAUGYIADATOK] (
    [ID]                            INT             IDENTITY (1, 1) NOT NULL,
    [C_ALKALMAZASKEZDETE]           DATETIME        NULL,
    [C_ALKALMAZASMEGSZUNESE]        DATETIME        NULL,
    [C_KEPESITES]                   INT             NULL,
    [C_KOTELEZOORASZAM]             NUMERIC (10, 2) NOT NULL,
    [C_MUNKAIDOKEDVEZMENYOKA]       INT             NULL,
    [C_MUNKAIDOKEDVEZMENYOKASZOVEG] NVARCHAR (MAX)  NULL,
    [C_MUNKAIDOKEDVEZMENYORASZAM]   INT             NULL,
    [C_MUNKAKORTIPUSA]              INT             NULL,
    [C_MUNKAVISZONYTIPUSA]          INT             NULL,
    [C_NYUGDIJAS]                   CHAR (1)        DEFAULT ('F') NOT NULL,
    [C_ISORAADO]                    CHAR (1)        DEFAULT ('F') NULL,
    [C_ALKALMAZOTTID]               INT             NOT NULL,
    [C_FELADATELLATASIHELYID]       INT             NULL,
    [C_INTEZMENYID]                 INT             NOT NULL,
    [C_TANEVID]                     INT             NOT NULL,
    [TOROLT]                        CHAR (1)        DEFAULT ('F') NULL,
    [SERIAL]                        INT             NULL,
    [LASTCHANGED]                   DATETIME        DEFAULT (getdate()) NULL,
    [CREATED]                       DATETIME        DEFAULT (getdate()) NULL,
    [MODIFIER]                      INT             NULL,
    [CREATOR]                       INT             NULL,
    CONSTRAINT [tmp_ms_xx_constraint_PK_T_40275581] PRIMARY KEY CLUSTERED ([ID] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [dbo].[T_TOVABBIMUNKAUGYIADATOK])
    BEGIN
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_TOVABBIMUNKAUGYIADATOK] ON;
        INSERT INTO [dbo].[tmp_ms_xx_T_TOVABBIMUNKAUGYIADATOK] ([ID], [C_ALKALMAZASKEZDETE], [C_ALKALMAZASMEGSZUNESE], [C_KEPESITES], [C_KOTELEZOORASZAM], [C_MUNKAIDOKEDVEZMENYOKA], [C_MUNKAIDOKEDVEZMENYOKASZOVEG], [C_MUNKAIDOKEDVEZMENYORASZAM], [C_MUNKAKORTIPUSA], [C_MUNKAVISZONYTIPUSA], [C_NYUGDIJAS], [C_ALKALMAZOTTID], [C_FELADATELLATASIHELYID], [C_INTEZMENYID], [C_TANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR])
        SELECT   [ID],
                 [C_ALKALMAZASKEZDETE],
                 [C_ALKALMAZASMEGSZUNESE],
                 [C_KEPESITES],
                 [C_KOTELEZOORASZAM],
                 [C_MUNKAIDOKEDVEZMENYOKA],
                 [C_MUNKAIDOKEDVEZMENYOKASZOVEG],
                 [C_MUNKAIDOKEDVEZMENYORASZAM],
                 [C_MUNKAKORTIPUSA],
                 [C_MUNKAVISZONYTIPUSA],
                 [C_NYUGDIJAS],
                 [C_ALKALMAZOTTID],
                 [C_FELADATELLATASIHELYID],
                 [C_INTEZMENYID],
                 [C_TANEVID],
                 [TOROLT],
                 [SERIAL],
                 [LASTCHANGED],
                 [CREATED],
                 [MODIFIER],
                 [CREATOR]
        FROM     [dbo].[T_TOVABBIMUNKAUGYIADATOK]
        ORDER BY [ID] ASC;
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_TOVABBIMUNKAUGYIADATOK] OFF;
    END

DROP TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK];

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_T_TOVABBIMUNKAUGYIADATOK]', N'T_TOVABBIMUNKAUGYIADATOK';

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_constraint_PK_T_40275581]', N'PK_T_4027558', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Creating [dbo].[T_TOVABBIMUNKAUGYIADATOK].[I_T_4027558_4027561]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4027558_4027561]
    ON [dbo].[T_TOVABBIMUNKAUGYIADATOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_KEPESITES] ASC);


GO
PRINT N'Creating [dbo].[T_TOVABBIMUNKAUGYIADATOK].[I_T_4027558_4027563]...';


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


GO
PRINT N'Creating [dbo].[T_TOVABBIMUNKAUGYIADATOK].[I_T_4027558_4027566]...';


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


GO
PRINT N'Creating [dbo].[T_TOVABBIMUNKAUGYIADATOK].[I_T_4027558_4027567]...';


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


GO
PRINT N'Creating [dbo].[T_TOVABBIMUNKAUGYIADATOK].[I_T_4027571_4027569]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4027571_4027569]
    ON [dbo].[T_TOVABBIMUNKAUGYIADATOK]([C_ALKALMAZOTTID] ASC);


GO
PRINT N'Creating [dbo].[T_TOVABBIMUNKAUGYIADATOK].[I_T_4027574_4027572]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4027574_4027572]
    ON [dbo].[T_TOVABBIMUNKAUGYIADATOK]([C_FELADATELLATASIHELYID] ASC);


GO
PRINT N'Creating [dbo].[T_TOVABBIMUNKAUGYIADATOK].[I_T_402755802_402755800]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402755802_402755800]
    ON [dbo].[T_TOVABBIMUNKAUGYIADATOK]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_TOVABBIMUNKAUGYIADATOK].[I_T_402755805_402755803]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402755805_402755803]
    ON [dbo].[T_TOVABBIMUNKAUGYIADATOK]([C_TANEVID] 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_KEPESITES], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_KEPESITES] ([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_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_4025712_4025710]...';


GO
ALTER TABLE [dbo].[T_TANULO_TANULOESEMENY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025712_4025710] FOREIGN KEY ([C_TANULOESEMENYID]) REFERENCES [dbo].[T_TANULOESEMENY] ([ID]);


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


GO
ALTER TABLE [dbo].[T_OSZTALYCSOPORT_TANULOESEMENY] WITH NOCHECK
    ADD CONSTRAINT [FK_4027557_4027555] FOREIGN KEY ([C_TANULOESEMENYID]) REFERENCES [dbo].[T_TANULOESEMENY] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025714_4025713] FOREIGN KEY ([C_FELJEGYZOID]) REFERENCES [dbo].[T_ALKALMAZOTT] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025942_4025941] FOREIGN KEY ([C_TANTARGYID]) REFERENCES [dbo].[T_TANTARGY] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENY] WITH NOCHECK
    ADD CONSTRAINT [FK_4027536_4027535] FOREIGN KEY ([C_TANITASIORAID]) REFERENCES [dbo].[T_TANITASIORA] ([ID]);


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025699_4025708] FOREIGN KEY ([C_TIPUS], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_ESEMENYTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4027558_4027561] FOREIGN KEY ([C_KEPESITES], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_KEPESITES] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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





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_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_TANULO_TANULOESEMENY] WITH CHECK CHECK CONSTRAINT [FK_4025712_4025710];

ALTER TABLE [dbo].[T_OSZTALYCSOPORT_TANULOESEMENY] WITH CHECK CHECK CONSTRAINT [FK_4027557_4027555];

ALTER TABLE [dbo].[T_TANULOESEMENY] WITH CHECK CHECK CONSTRAINT [FK_4025714_4025713];

ALTER TABLE [dbo].[T_TANULOESEMENY] WITH CHECK CHECK CONSTRAINT [FK_4025942_4025941];

ALTER TABLE [dbo].[T_TANULOESEMENY] WITH CHECK CHECK CONSTRAINT [FK_4027536_4027535];

ALTER TABLE [dbo].[T_TANULOESEMENY] WITH CHECK CHECK CONSTRAINT [FK_402569902_402569900];

ALTER TABLE [dbo].[T_TANULOESEMENY] WITH CHECK CHECK CONSTRAINT [FK_402569905_402569903];

ALTER TABLE [dbo].[T_TANULOESEMENY] WITH CHECK CHECK CONSTRAINT [FK_4025699_4025708];

ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4027558_4027561];

ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4027558_4027563];

ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4027558_4027566];

ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4027558_4027567];

ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4027571_4027569];

ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4027574_4027572];

ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_402755802_402755800];

ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_402755805_402755803];


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_MUNKAUGYIADATOK', 'T_MUNKAUGYIADATOK_OSSZES',
  'T_TOVABBIMUNKAUGYIADATOK', 'T_TOVABBIMUNKAUGYIADATOK_OSSZES',
  'T_TANULOESEMENY', 'T_TANULOESEMENY_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
