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

SET NUMERIC_ROUNDABORT OFF;


GO


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


GO
ALTER TABLE [dbo].[T_FELHASZNALOBELEPES] DROP CONSTRAINT [FK_4025031_4025029];


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


GO
ALTER TABLE [dbo].[T_FELHASZNALOBELEPES] DROP CONSTRAINT [FK_4025187_4025186];


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


GO
ALTER TABLE [dbo].[T_FELHASZNALOBELEPES] DROP CONSTRAINT [FK_402502202_402502200];


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


GO
ALTER TABLE [dbo].[T_FELHASZNALOBELEPES] DROP CONSTRAINT [FK_402502205_402502203];


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


GO
ALTER TABLE [dbo].[T_TANULOERTEKELES] DROP CONSTRAINT [FK_4025938_4025937];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_4025602_4025601];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_4025608_4025607];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_4025611_4025610];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_4025620_4025619];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_4025623_4025622];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_4025629_4025628];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_4025635_4025634];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_4025638_4025637];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_4026315_4026314];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_402557502_402557500];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_402557505_402557503];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_4025575_4025580];


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] DROP CONSTRAINT [FK_4025575_4025581];


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


GO
ALTER TABLE [dbo].[T_ORALATOGATAS] DROP CONSTRAINT [FK_4025795_4025794];


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_4025632_4025631]...';


GO
ALTER TABLE [dbo].[T_ORAK_TANAROK] DROP CONSTRAINT [FK_4025632_4025631];


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


GO
ALTER TABLE [dbo].[T_TANULOMULASZTAS] DROP CONSTRAINT [FK_4025674_4025672];


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


GO
ALTER TABLE [dbo].[T_GONDVISELO] DROP CONSTRAINT [FK_4025181_4025180];


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


GO
ALTER TABLE [dbo].[T_TANULOERTEKELES] DROP CONSTRAINT [FK_4025665_4025663];


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


GO
ALTER TABLE [dbo].[T_TANULOESLADATOK] DROP CONSTRAINT [FK_4026674_4026673];


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


GO
ALTER TABLE [dbo].[T_TANULOTARGYMULASZTASSTATISZT] DROP CONSTRAINT [FK_4026076_4026075];


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


GO
ALTER TABLE [dbo].[T_TANULOMULASZTASSTATISZTIKA] DROP CONSTRAINT [FK_4026073_4026072];


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


GO
ALTER TABLE [dbo].[T_TANULOMENTESSEG] DROP CONSTRAINT [FK_4025780_4025778];


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


GO
ALTER TABLE [dbo].[T_TANULOCSOPORT] DROP CONSTRAINT [FK_4025527_4025525];


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


GO
ALTER TABLE [dbo].[T_IGAZOLAS] DROP CONSTRAINT [FK_4025758_4025756];


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


GO
ALTER TABLE [dbo].[T_ERETTSEGIEREDMENY] DROP CONSTRAINT [FK_4027621_4027620];


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


GO
ALTER TABLE [dbo].[T_DIAKIGAZOLVANYIGENYLES] DROP CONSTRAINT [FK_4025788_4025787];


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


GO
ALTER TABLE [dbo].[T_TANULOKOZOSSEGISZOLGALAT] DROP CONSTRAINT [FK_4026179_4026177];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_T_8935_4025190];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025416_4025415];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4026237_4026236];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_402517802_402517800];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_402517805_402517803];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4025259];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4025262];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4025274];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4025344];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4025346];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4025357];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4025488];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4025493];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4025495];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4027540];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4027541];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4027542];


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


GO
ALTER TABLE [dbo].[T_TANULO] DROP CONSTRAINT [FK_4025178_4027543];


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


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


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


GO
ALTER TABLE [dbo].[T_TANULOMULASZTAS] DROP CONSTRAINT [FK_4025673_4025672];


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


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [dbo].[tmp_ms_xx_T_FELHASZNALOBELEPES] (
    [ID]                       INT            IDENTITY (1, 1) NOT NULL,
    [C_KOTELEZOVALTOZTATNI]    CHAR (1)       DEFAULT ('T') NULL,
    [C_MEGHIUSULTBELEPESEK]    INT            NULL,
    [C_UTOLSOBELEPES]          DATETIME       NULL,
    [C_JELSZO]                 NVARCHAR (64)  NULL,
    [C_JELSZOVALTOZTATASIDEJE] DATETIME       NULL,
    [C_SO]                     NVARCHAR (64)  NULL,
    [C_BEJELENTKEZESINEV]      NVARCHAR (255) NOT NULL,
    [C_NEPTUNNAPLOJELSZO]      NVARCHAR (64)  NULL,
    [C_GUID]                   NVARCHAR (36)  NULL,
    [C_FELHASZNALOID]          INT            NOT NULL,
    [C_GONDVISELOID]           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,
	[NNID]					   INT			  NULL,
	[ELOZOTANEVIREKORDID]	   INT			  NULL
    CONSTRAINT [tmp_ms_xx_constraint_PK_T_40250221] PRIMARY KEY CLUSTERED ([ID] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [dbo].[T_FELHASZNALOBELEPES])
    BEGIN
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_FELHASZNALOBELEPES] ON;
        INSERT INTO [dbo].[tmp_ms_xx_T_FELHASZNALOBELEPES] ([ID], [C_KOTELEZOVALTOZTATNI], [C_MEGHIUSULTBELEPESEK], [C_UTOLSOBELEPES], [C_JELSZO], [C_JELSZOVALTOZTATASIDEJE], [C_SO], [C_BEJELENTKEZESINEV], [C_NEPTUNNAPLOJELSZO], [C_GUID], [C_FELHASZNALOID], [C_GONDVISELOID], [C_INTEZMENYID], [C_TANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR], [NNID], [ELOZOTANEVIREKORDID])
        SELECT   [ID],
                 [C_KOTELEZOVALTOZTATNI],
                 [C_MEGHIUSULTBELEPESEK],
                 [C_UTOLSOBELEPES],
                 [C_JELSZO],
                 [C_JELSZOVALTOZTATASIDEJE],
                 [C_SO],
                 [C_BEJELENTKEZESINEV],
                 [C_NEPTUNNAPLOJELSZO],
				 NEWID(),
                 [C_FELHASZNALOID],
                 [C_GONDVISELOID],
                 [C_INTEZMENYID],
                 [C_TANEVID],
                 [TOROLT],
                 [SERIAL],
                 [LASTCHANGED],
                 [CREATED],
                 [MODIFIER],
                 [CREATOR],
				 [NNID],
				 [ELOZOTANEVIREKORDID]
        FROM     [dbo].[T_FELHASZNALOBELEPES]
        ORDER BY [ID] ASC;
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_FELHASZNALOBELEPES] OFF;
    END

DROP TABLE [dbo].[T_FELHASZNALOBELEPES];

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_T_FELHASZNALOBELEPES]', N'T_FELHASZNALOBELEPES';

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_constraint_PK_T_40250221]', N'PK_T_4025022', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Creating [dbo].[T_FELHASZNALOBELEPES].[I_T_4025031_4025029]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025031_4025029]
    ON [dbo].[T_FELHASZNALOBELEPES]([C_FELHASZNALOID] ASC);


GO
PRINT N'Creating [dbo].[T_FELHASZNALOBELEPES].[I_T_4025187_4025186]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025187_4025186]
    ON [dbo].[T_FELHASZNALOBELEPES]([C_GONDVISELOID] ASC);


GO
PRINT N'Creating [dbo].[T_FELHASZNALOBELEPES].[I_T_402502202_402502200]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402502202_402502200]
    ON [dbo].[T_FELHASZNALOBELEPES]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_FELHASZNALOBELEPES].[I_T_402502205_402502203]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402502205_402502203]
    ON [dbo].[T_FELHASZNALOBELEPES]([C_TANEVID] ASC);


GO
PRINT N'Creating [dbo].[T_FELHASZNALOBELEPES].[UK_4025364]...';


GO
CREATE UNIQUE NONCLUSTERED INDEX [UK_4025364]
    ON [dbo].[T_FELHASZNALOBELEPES]([C_BEJELENTKEZESINEV] ASC, [C_INTEZMENYID] ASC, [C_TANEVID] ASC) WHERE ([TOROLT]='F');


--GO
--PRINT N'Creating [dbo].[T_FELHASZNALOBELEPES].[UK_4027897]...';


--GO
--CREATE UNIQUE NONCLUSTERED INDEX [UK_4027897]
--    ON [dbo].[T_FELHASZNALOBELEPES]([C_GUID] ASC, [C_INTEZMENYID] ASC, [C_TANEVID] ASC) WHERE ([TOROLT]='F');


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


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [dbo].[tmp_ms_xx_T_TANITASIORA] (
    [ID]                         INT             IDENTITY (1, 1) NOT NULL,
    [C_BEJEGYZESIDEJE]           DATETIME        NOT NULL,
    [C_BONTOTT]                  CHAR (1)        DEFAULT ('F') NULL,
    [C_DATUM]                    DATETIME        NOT NULL,
    [C_HELYETTESITESOKA]         NVARCHAR (255)  NULL,
    [C_HELYETTESITESTIPUSA]      INT             NULL,
    [C_HETNAPJA]                 INT             NOT NULL,
    [C_HETSORSZAMA]              INT             NOT NULL,
    [C_IKTTANORA]                CHAR (1)        DEFAULT ('F') NULL,
    [C_MEGJEGYZES]               NVARCHAR (255)  NULL,
    [C_MEGTARTOTT]               CHAR (1)        DEFAULT ('T') NULL,
    [C_NAPSORSZAMA]              INT             NOT NULL,
    [C_NEMSZAKRENDSZERUORA]      CHAR (1)        DEFAULT ('F') NULL,
    [C_ORAKEZDETE]               DATETIME        NOT NULL,
    [C_ORASZAM]                  INT             NOT NULL,
    [C_ORAVEGE]                  DATETIME        NOT NULL,
    [C_SORSZAMOZANDO]            CHAR (1)        NULL,
    [C_TAMOPORA]                 CHAR (1)        DEFAULT ('F') NULL,
    [C_TEMA]                     NVARCHAR (1000) NULL,
    [C_TULORA]                   CHAR (1)        DEFAULT ('F') NULL,
    [C_OSZTALYFONOKI]            CHAR (1)        DEFAULT ('F') NULL,
    [C_TANORANKIVULIFOGLALKOZAS] CHAR (1)        DEFAULT ('F') NULL,
    [C_HAZIFELADAT]              NVARCHAR (MAX)  NULL,
    [C_DIFFERENCIALT]            CHAR (1)        NULL,
    [C_DRAMA]                    CHAR (1)        NULL,
    [C_IPRTANORA]                CHAR (1)        NULL,
    [C_KOOPERATIV]               CHAR (1)        NULL,
    [C_MERES]                    CHAR (1)        NULL,
    [C_MINDENNAPOSTESTNEVELES]   CHAR (1)        NULL,
    [C_NEMZETISEGIORA]           CHAR (1)        NULL,
    [C_PARHUZAMOSORA]            CHAR (1)        NULL,
    [C_TIOP12]                   CHAR (1)        NULL,
    [C_ADMINALTALKIIRT]          CHAR (1)        NULL,
    [C_CSENGETESIRENDID]         INT             NULL,
    [C_CSENGETESIRENDORAID]      INT             NULL,
    [C_TANMENETID]               INT             NULL,
    [C_TANTARGYID]               INT             NULL,
    [C_NAPTARINAPID]             INT             NULL,
    [C_ORARENDIORAID]            INT             NULL,
    [C_FOGLALKOZASID]            INT             NULL,
    [C_HELYETTESITOTANARID]      INT             NULL,
    [C_TEREMID]                  INT             NULL,
    [C_OSZTALYCSOPORTID]         INT             NULL,
    [C_ORATULAJDONOSID]          INT             NOT NULL,
    [C_UPLOADEDFILEID]           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_40255751] PRIMARY KEY CLUSTERED ([ID] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [dbo].[T_TANITASIORA])
    BEGIN
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_TANITASIORA] ON;
        INSERT INTO [dbo].[tmp_ms_xx_T_TANITASIORA] ([ID], [C_BEJEGYZESIDEJE], [C_BONTOTT], [C_DATUM], [C_HELYETTESITESOKA], [C_HELYETTESITESTIPUSA], [C_HETNAPJA], [C_HETSORSZAMA], [C_IKTTANORA], [C_MEGJEGYZES], [C_MEGTARTOTT], [C_NAPSORSZAMA], [C_NEMSZAKRENDSZERUORA], [C_ORAKEZDETE], [C_ORASZAM], [C_ORAVEGE], [C_SORSZAMOZANDO], [C_TAMOPORA], [C_TEMA], [C_TULORA], [C_OSZTALYFONOKI], [C_TANORANKIVULIFOGLALKOZAS], [C_HAZIFELADAT], [C_DIFFERENCIALT], [C_DRAMA], [C_IPRTANORA], [C_KOOPERATIV], [C_MERES], [C_MINDENNAPOSTESTNEVELES], [C_NEMZETISEGIORA], [C_PARHUZAMOSORA], [C_TIOP12], [C_ADMINALTALKIIRT], [C_CSENGETESIRENDID], [C_CSENGETESIRENDORAID], [C_TANMENETID], [C_TANTARGYID], [C_NAPTARINAPID], [C_ORARENDIORAID], [C_FOGLALKOZASID], [C_HELYETTESITOTANARID], [C_TEREMID], [C_OSZTALYCSOPORTID], [C_ORATULAJDONOSID], [C_INTEZMENYID], [C_TANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR])
        SELECT   [ID],
                 [C_BEJEGYZESIDEJE],
                 [C_BONTOTT],
                 [C_DATUM],
                 [C_HELYETTESITESOKA],
                 [C_HELYETTESITESTIPUSA],
                 [C_HETNAPJA],
                 [C_HETSORSZAMA],
                 [C_IKTTANORA],
                 [C_MEGJEGYZES],
                 [C_MEGTARTOTT],
                 [C_NAPSORSZAMA],
                 [C_NEMSZAKRENDSZERUORA],
                 [C_ORAKEZDETE],
                 [C_ORASZAM],
                 [C_ORAVEGE],
                 [C_SORSZAMOZANDO],
                 [C_TAMOPORA],
                 [C_TEMA],
                 [C_TULORA],
                 [C_OSZTALYFONOKI],
                 [C_TANORANKIVULIFOGLALKOZAS],
                 [C_HAZIFELADAT],
                 [C_DIFFERENCIALT],
                 [C_DRAMA],
                 [C_IPRTANORA],
                 [C_KOOPERATIV],
                 [C_MERES],
                 [C_MINDENNAPOSTESTNEVELES],
                 [C_NEMZETISEGIORA],
                 [C_PARHUZAMOSORA],
                 [C_TIOP12],
                 [C_ADMINALTALKIIRT],
                 [C_CSENGETESIRENDID],
                 [C_CSENGETESIRENDORAID],
                 [C_TANMENETID],
                 [C_TANTARGYID],
                 [C_NAPTARINAPID],
                 [C_ORARENDIORAID],
                 [C_FOGLALKOZASID],
                 [C_HELYETTESITOTANARID],
                 [C_TEREMID],
                 [C_OSZTALYCSOPORTID],
                 [C_ORATULAJDONOSID],
                 [C_INTEZMENYID],
                 [C_TANEVID],
                 [TOROLT],
                 [SERIAL],
                 [LASTCHANGED],
                 [CREATED],
                 [MODIFIER],
                 [CREATOR]
        FROM     [dbo].[T_TANITASIORA]
        ORDER BY [ID] ASC;
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_TANITASIORA] OFF;
    END

DROP TABLE [dbo].[T_TANITASIORA];

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_T_TANITASIORA]', N'T_TANITASIORA';

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_constraint_PK_T_40255751]', N'PK_T_4025575', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4025575_4025580]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025575_4025580]
    ON [dbo].[T_TANITASIORA]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_HELYETTESITESTIPUSA] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4025575_4025581]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025575_4025581]
    ON [dbo].[T_TANITASIORA]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_HETNAPJA] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4025602_4025601]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025602_4025601]
    ON [dbo].[T_TANITASIORA]([C_TANMENETID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4025608_4025607]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025608_4025607]
    ON [dbo].[T_TANITASIORA]([C_TANTARGYID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4025611_4025610]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025611_4025610]
    ON [dbo].[T_TANITASIORA]([C_NAPTARINAPID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4025620_4025619]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025620_4025619]
    ON [dbo].[T_TANITASIORA]([C_ORARENDIORAID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4025623_4025622]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025623_4025622]
    ON [dbo].[T_TANITASIORA]([C_FOGLALKOZASID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4025629_4025628]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025629_4025628]
    ON [dbo].[T_TANITASIORA]([C_HELYETTESITOTANARID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4025635_4025634]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025635_4025634]
    ON [dbo].[T_TANITASIORA]([C_TEREMID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4025638_4025637]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025638_4025637]
    ON [dbo].[T_TANITASIORA]([C_OSZTALYCSOPORTID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4026315_4026314]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026315_4026314]
    ON [dbo].[T_TANITASIORA]([C_ORATULAJDONOSID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_4027901_4027900]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4027901_4027900]
    ON [dbo].[T_TANITASIORA]([C_UPLOADEDFILEID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_402557502_402557500]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402557502_402557500]
    ON [dbo].[T_TANITASIORA]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_TANITASIORA].[I_T_402557505_402557503]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402557505_402557503]
    ON [dbo].[T_TANITASIORA]([C_TANEVID] ASC);


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


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [dbo].[tmp_ms_xx_T_TANULO] (
    [ID]                             INT             NOT NULL,
    [C_ALLAMIGONDOZOTT]              CHAR (1)        NULL,
    [C_BANKSZAMLASZAM]               NVARCHAR (24)   NULL,
    [C_BEILLESZKEDESINEHEZSEG]       CHAR (1)        NULL,
    [C_BEIRASINAPLOSORSZAM]          NVARCHAR (50)   NULL,
    [C_BEJARO]                       CHAR (1)        NULL,
    [C_DIAKIGAZOLVANYKELTE]          DATETIME        NULL,
    [C_DIAKIGAZOLVANYSZAM]           NVARCHAR (255)  NULL,
    [C_ELOZOINTEZMENY]               NVARCHAR (255)  NULL,
    [C_EVISMETLO]                    CHAR (1)        NULL,
    [C_INGYENESTANKONVYELLATASA]     INT             NULL,
    [C_JOGVISZONYATSZUNETELTETO]     CHAR (1)        NULL,
    [C_MAGANTANULO]                  CHAR (1)        NULL,
    [C_MAGANTANULOSAGANAKOKA]        INT             NULL,
    [C_MAGANTANULOSAGKEZDETE]        DATETIME        NULL,
    [C_NAPLOSORSZAM]                 INT             NULL,
    [C_POLGARISZERZODESES]           CHAR (1)        NULL,
    [C_SZAKMAIGYAKORLATON]           CHAR (1)        NULL,
    [C_SZOCIALISTAMOGATAS]           CHAR (1)        NULL,
    [C_TANDIJATFIZETO]               CHAR (1)        NULL,
    [C_TANKOTELEZETT]                CHAR (1)        NULL,
    [C_TANKOTELEZETTSEGVEGE]         DATETIME        NULL,
    [C_TANULOSZERZODESES]            CHAR (1)        NULL,
    [C_TERITESIDIJATFIZETO]          CHAR (1)        NULL,
    [C_TESTNEVELESTIPUSA]            INT             NULL,
    [C_VENDEG]                       CHAR (1)        NULL,
    [C_BTMPROBLEMAS]                 CHAR (1)        DEFAULT ('F') NULL,
    [C_DIAKSPORTKOROS]               CHAR (1)        NULL,
    [C_EGYHAZKOZOSSEGE]              NVARCHAR (255)  NULL,
    [C_ETKEZESIKEDVEZMENY]           INT             NULL,
    [C_HALMOZOTTANFOGYATEKOS]        CHAR (1)        DEFAULT ('F') NULL,
    [C_HATRANYOSHELYZETU]            INT             NULL,
    [C_KOLLEGIUMIELLATASOS]          CHAR (1)        DEFAULT ('F') NULL,
    [C_RENDSZERESGYERMEKVEDELMIKEDV] NVARCHAR (255)  NULL,
    [C_SAJATOSNEVELESU]              CHAR (1)        DEFAULT ('F') NULL,
    [C_SPORTAG]                      NVARCHAR (255)  NULL,
    [C_SPORTEDZONEVE]                NVARCHAR (1000) NULL,
    [C_SPORTKLUB]                    NVARCHAR (100)  NULL,
    [C_SZAKKEPESITESSZAMA]           INT             NULL,
    [C_TANULOIJOGVISZONYOSELTARTOTT] INT             NULL,
    [C_TARTOSGYOGYKEZELESSZAMA]      NVARCHAR (255)  NULL,
    [C_TOBBGYERMEKIGAZOLASSZAMA]     NVARCHAR (255)  NULL,
    [C_VALLASA]                      INT             NULL,
    [C_VESZELYEZTETETT]              CHAR (1)        DEFAULT ('F') NULL,
    [C_JOGVISZONYVARHATOBEFEJEZESE]  DATETIME        NULL,
    [C_BEILLESZKEDESIPROBLEMAVALKUZ] CHAR (1)        NULL,
    [C_BESZEDFOGYATEKOSOKMANYSZAM]   NVARCHAR (100)  NULL,
    [C_BNOKOD]                       NVARCHAR (100)  NULL,
    [C_BTMHATAROZATOKMANYSZAM]       NVARCHAR (255)  NULL,
    [C_BTMHATAROZATTARTALMA]         NVARCHAR (1000) NULL,
    [C_BTMKIALLITOINTEZMENY]         NVARCHAR (255)  NULL,
    [C_BTMKONTROLLIDOPONT]           DATETIME        NULL,
    [C_BTMLETSZAMSULY]               NUMERIC (10, 2) NULL,
    [C_BTMOKMANYERVENYESSEGKEZDETE]  DATETIME        NULL,
    [C_BTMOKMANYERVENYESSEGVEGE]     DATETIME        NULL,
    [C_DISZGRAFIAOKMANYSZAM]         NVARCHAR (100)  NULL,
    [C_DISZKALKULIAOKMANYSZAM]       NVARCHAR (255)  NULL,
    [C_DISZLEXIAOKMANYSZAM]          NVARCHAR (255)  NULL,
    [C_ERTELMIFOGYATEKOS]            INT             NULL,
    [C_ERTELMIFOGYATEKOSOKMANYSZAM]  NVARCHAR (30)   NULL,
    [C_FEJLESZTESREKIJELOLT]         NVARCHAR (255)  NULL,
    [C_FEJLESZTOFOGLALKOZAS]         NVARCHAR (255)  NULL,
    [C_FEJLESZTOFOGLALKOZASORASZAM]  NUMERIC (10, 2) NULL,
    [C_HALLASSERULT]                 INT             NULL,
    [C_HALLASSERULTOKMANYSZAM]       NVARCHAR (100)  NULL,
    [C_LATASSERULT]                  INT             NULL,
    [C_LATASSERULTOKMANYSZAM]        NVARCHAR (100)  NULL,
    [C_MAGATARTASIPROBLEMAVALKUZD]   CHAR (1)        NULL,
    [C_MEGISMERONEMORGANIKUSOKMANYS] NVARCHAR (100)  NULL,
    [C_MEGISMEROORGANIKUSOKMANYSZAM] NVARCHAR (100)  NULL,
    [C_MOZGASSERULTOKMANYSZAM]       NVARCHAR (255)  NULL,
    [C_SNIKIALLITOINTEZMENY]         NVARCHAR (255)  NULL,
    [C_SNIKONTROLLIDOPONT]           DATETIME        NULL,
    [C_SNILETSZAMSULY]               NUMERIC (10, 2) NULL,
    [C_SNIMEGHATAROZAS]              NVARCHAR (255)  NULL,
    [C_SNIOKMANYERVENYESSEGKEZDETE]  DATETIME        NULL,
    [C_SNIOKMANYERVENYESSEGVEGE]     DATETIME        NULL,
    [C_TANULASIPROBLEMADISZGRAFIA]   CHAR (1)        NULL,
    [C_TANULASIPROBLEMAVALKUZD]      CHAR (1)        NULL,
    [C_TANULASIPROBLEMAVALKUZDDISZK] CHAR (1)        NULL,
    [C_TANULASIPROBLEMAVALKUZDDISZL] CHAR (1)        NULL,
    [C_VISELKEDESNEMORGANIKUSOKMANY] NVARCHAR (100)  NULL,
    [C_VISELKEDESORGANIKUSOKMANYSZA] NVARCHAR (100)  NULL,
    [C_ELSOINTEZMENYOMKOD]           NVARCHAR (12)   NULL,
    [C_EVISMETLOTANTARGYAK]          NVARCHAR (1000) NULL,
    [C_KOZEPFOKUOKTATASBATIZENHATOD] CHAR (1)        NULL,
    [C_MENEDEKJOGGALRENDELKEZO]      CHAR (1)        NULL,
    [C_AGAZAT]                       INT             NULL,
    [C_RESZSZAKKEPESITES]            INT             NULL,
    [C_SZAKKEPESITES]                INT             NULL,
    [C_SZAKMACSOPORT]                INT             NULL,
    [C_EGYEBDONTO]                   CHAR (1)        DEFAULT ('F') NULL,
    [C_MEGALLAPODASOS]               CHAR (1)        DEFAULT ('F') NULL,
    [C_OSZTV]                        CHAR (1)        DEFAULT ('F') NULL,
    [C_SZETVAGAZAT]                  CHAR (1)        DEFAULT ('F') NULL,
    [C_SZINTVIZSGA]                  NUMERIC (10, 2) NULL,
    [C_SZKTV]                        CHAR (1)        DEFAULT ('F') NULL,
    [C_TECHNIKUSIEVFOLYAM]           CHAR (1)        DEFAULT ('F') NULL,
    [C_EGYUTTMUKODESES]              CHAR (1)        DEFAULT ('F') NULL,
    [C_ISKOLAIKERETEKKOZOTT]         CHAR (1)        DEFAULT ('F') NULL,
    [C_TANTERVID]                    INT             NOT NULL,
    [C_FELVETELTANEVEID]             INT             NOT NULL,
    [C_ALINTEZMENYID]                INT             NOT NULL,
    [C_ALTANEVID]                    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_40251781] PRIMARY KEY CLUSTERED ([ID] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [dbo].[T_TANULO])
    BEGIN
        INSERT INTO [dbo].[tmp_ms_xx_T_TANULO] ([ID], [C_ALLAMIGONDOZOTT], [C_BANKSZAMLASZAM], [C_BEILLESZKEDESINEHEZSEG], [C_BEIRASINAPLOSORSZAM], [C_BEJARO], [C_DIAKIGAZOLVANYKELTE], [C_DIAKIGAZOLVANYSZAM], [C_ELOZOINTEZMENY], [C_EVISMETLO], [C_INGYENESTANKONVYELLATASA], [C_JOGVISZONYATSZUNETELTETO], [C_MAGANTANULO], [C_MAGANTANULOSAGANAKOKA], [C_MAGANTANULOSAGKEZDETE], [C_NAPLOSORSZAM], [C_POLGARISZERZODESES], [C_SZAKMAIGYAKORLATON], [C_SZOCIALISTAMOGATAS], [C_TANDIJATFIZETO], [C_TANKOTELEZETT], [C_TANKOTELEZETTSEGVEGE], [C_TANULOSZERZODESES], [C_TERITESIDIJATFIZETO], [C_TESTNEVELESTIPUSA], [C_VENDEG], [C_BTMPROBLEMAS], [C_DIAKSPORTKOROS], [C_EGYHAZKOZOSSEGE], [C_ETKEZESIKEDVEZMENY], [C_HALMOZOTTANFOGYATEKOS], [C_HATRANYOSHELYZETU], [C_KOLLEGIUMIELLATASOS], [C_RENDSZERESGYERMEKVEDELMIKEDV], [C_SAJATOSNEVELESU], [C_SPORTAG], [C_SPORTEDZONEVE], [C_SPORTKLUB], [C_SZAKKEPESITESSZAMA], [C_TANULOIJOGVISZONYOSELTARTOTT], [C_TARTOSGYOGYKEZELESSZAMA], [C_TOBBGYERMEKIGAZOLASSZAMA], [C_VALLASA], [C_VESZELYEZTETETT], [C_JOGVISZONYVARHATOBEFEJEZESE], [C_BEILLESZKEDESIPROBLEMAVALKUZ], [C_BESZEDFOGYATEKOSOKMANYSZAM], [C_BNOKOD], [C_BTMHATAROZATOKMANYSZAM], [C_BTMHATAROZATTARTALMA], [C_BTMKIALLITOINTEZMENY], [C_BTMKONTROLLIDOPONT], [C_BTMLETSZAMSULY], [C_BTMOKMANYERVENYESSEGKEZDETE], [C_BTMOKMANYERVENYESSEGVEGE], [C_DISZGRAFIAOKMANYSZAM], [C_DISZKALKULIAOKMANYSZAM], [C_DISZLEXIAOKMANYSZAM], [C_ERTELMIFOGYATEKOS], [C_ERTELMIFOGYATEKOSOKMANYSZAM], [C_FEJLESZTESREKIJELOLT], [C_FEJLESZTOFOGLALKOZAS], [C_FEJLESZTOFOGLALKOZASORASZAM], [C_HALLASSERULT], [C_HALLASSERULTOKMANYSZAM], [C_LATASSERULT], [C_LATASSERULTOKMANYSZAM], [C_MAGATARTASIPROBLEMAVALKUZD], [C_MEGISMERONEMORGANIKUSOKMANYS], [C_MEGISMEROORGANIKUSOKMANYSZAM], [C_MOZGASSERULTOKMANYSZAM], [C_SNIKIALLITOINTEZMENY], [C_SNIKONTROLLIDOPONT], [C_SNILETSZAMSULY], [C_SNIMEGHATAROZAS], [C_SNIOKMANYERVENYESSEGKEZDETE], [C_SNIOKMANYERVENYESSEGVEGE], [C_TANULASIPROBLEMADISZGRAFIA], [C_TANULASIPROBLEMAVALKUZD], [C_TANULASIPROBLEMAVALKUZDDISZK], [C_TANULASIPROBLEMAVALKUZDDISZL], [C_VISELKEDESNEMORGANIKUSOKMANY], [C_VISELKEDESORGANIKUSOKMANYSZA], [C_ELSOINTEZMENYOMKOD], [C_EVISMETLOTANTARGYAK], [C_KOZEPFOKUOKTATASBATIZENHATOD], [C_MENEDEKJOGGALRENDELKEZO], [C_AGAZAT], [C_RESZSZAKKEPESITES], [C_SZAKKEPESITES], [C_SZAKMACSOPORT], [C_EGYEBDONTO], [C_MEGALLAPODASOS], [C_OSZTV], [C_SZETVAGAZAT], [C_SZINTVIZSGA], [C_SZKTV], [C_TECHNIKUSIEVFOLYAM], [C_TANTERVID], [C_FELVETELTANEVEID], [C_ALINTEZMENYID], [C_ALTANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR])
        SELECT   [ID],
                 [C_ALLAMIGONDOZOTT],
                 [C_BANKSZAMLASZAM],
                 [C_BEILLESZKEDESINEHEZSEG],
                 [C_BEIRASINAPLOSORSZAM],
                 [C_BEJARO],
                 [C_DIAKIGAZOLVANYKELTE],
                 [C_DIAKIGAZOLVANYSZAM],
                 [C_ELOZOINTEZMENY],
                 [C_EVISMETLO],
                 [C_INGYENESTANKONVYELLATASA],
                 [C_JOGVISZONYATSZUNETELTETO],
                 [C_MAGANTANULO],
                 [C_MAGANTANULOSAGANAKOKA],
                 [C_MAGANTANULOSAGKEZDETE],
                 [C_NAPLOSORSZAM],
                 [C_POLGARISZERZODESES],
                 [C_SZAKMAIGYAKORLATON],
                 [C_SZOCIALISTAMOGATAS],
                 [C_TANDIJATFIZETO],
                 [C_TANKOTELEZETT],
                 [C_TANKOTELEZETTSEGVEGE],
                 [C_TANULOSZERZODESES],
                 [C_TERITESIDIJATFIZETO],
                 [C_TESTNEVELESTIPUSA],
                 [C_VENDEG],
                 [C_BTMPROBLEMAS],
                 [C_DIAKSPORTKOROS],
                 [C_EGYHAZKOZOSSEGE],
                 [C_ETKEZESIKEDVEZMENY],
                 [C_HALMOZOTTANFOGYATEKOS],
                 [C_HATRANYOSHELYZETU],
                 [C_KOLLEGIUMIELLATASOS],
                 [C_RENDSZERESGYERMEKVEDELMIKEDV],
                 [C_SAJATOSNEVELESU],
                 [C_SPORTAG],
                 [C_SPORTEDZONEVE],
                 [C_SPORTKLUB],
                 [C_SZAKKEPESITESSZAMA],
                 [C_TANULOIJOGVISZONYOSELTARTOTT],
                 [C_TARTOSGYOGYKEZELESSZAMA],
                 [C_TOBBGYERMEKIGAZOLASSZAMA],
                 [C_VALLASA],
                 [C_VESZELYEZTETETT],
                 [C_JOGVISZONYVARHATOBEFEJEZESE],
                 [C_BEILLESZKEDESIPROBLEMAVALKUZ],
                 [C_BESZEDFOGYATEKOSOKMANYSZAM],
                 [C_BNOKOD],
                 [C_BTMHATAROZATOKMANYSZAM],
                 [C_BTMHATAROZATTARTALMA],
                 [C_BTMKIALLITOINTEZMENY],
                 [C_BTMKONTROLLIDOPONT],
                 [C_BTMLETSZAMSULY],
                 [C_BTMOKMANYERVENYESSEGKEZDETE],
                 [C_BTMOKMANYERVENYESSEGVEGE],
                 [C_DISZGRAFIAOKMANYSZAM],
                 [C_DISZKALKULIAOKMANYSZAM],
                 [C_DISZLEXIAOKMANYSZAM],
                 [C_ERTELMIFOGYATEKOS],
                 [C_ERTELMIFOGYATEKOSOKMANYSZAM],
                 [C_FEJLESZTESREKIJELOLT],
                 [C_FEJLESZTOFOGLALKOZAS],
                 [C_FEJLESZTOFOGLALKOZASORASZAM],
                 [C_HALLASSERULT],
                 [C_HALLASSERULTOKMANYSZAM],
                 [C_LATASSERULT],
                 [C_LATASSERULTOKMANYSZAM],
                 [C_MAGATARTASIPROBLEMAVALKUZD],
                 [C_MEGISMERONEMORGANIKUSOKMANYS],
                 [C_MEGISMEROORGANIKUSOKMANYSZAM],
                 [C_MOZGASSERULTOKMANYSZAM],
                 [C_SNIKIALLITOINTEZMENY],
                 [C_SNIKONTROLLIDOPONT],
                 [C_SNILETSZAMSULY],
                 [C_SNIMEGHATAROZAS],
                 [C_SNIOKMANYERVENYESSEGKEZDETE],
                 [C_SNIOKMANYERVENYESSEGVEGE],
                 [C_TANULASIPROBLEMADISZGRAFIA],
                 [C_TANULASIPROBLEMAVALKUZD],
                 [C_TANULASIPROBLEMAVALKUZDDISZK],
                 [C_TANULASIPROBLEMAVALKUZDDISZL],
                 [C_VISELKEDESNEMORGANIKUSOKMANY],
                 [C_VISELKEDESORGANIKUSOKMANYSZA],
                 [C_ELSOINTEZMENYOMKOD],
                 [C_EVISMETLOTANTARGYAK],
                 [C_KOZEPFOKUOKTATASBATIZENHATOD],
                 [C_MENEDEKJOGGALRENDELKEZO],
                 [C_AGAZAT],
                 [C_RESZSZAKKEPESITES],
                 [C_SZAKKEPESITES],
                 [C_SZAKMACSOPORT],
                 [C_EGYEBDONTO],
                 [C_MEGALLAPODASOS],
                 [C_OSZTV],
                 [C_SZETVAGAZAT],
                 [C_SZINTVIZSGA],
                 [C_SZKTV],
                 [C_TECHNIKUSIEVFOLYAM],
                 [C_TANTERVID],
                 [C_FELVETELTANEVEID],
                 [C_ALINTEZMENYID],
                 [C_ALTANEVID],
                 [TOROLT],
                 [SERIAL],
                 [LASTCHANGED],
                 [CREATED],
                 [MODIFIER],
                 [CREATOR]
        FROM     [dbo].[T_TANULO]
        ORDER BY [ID] ASC;
    END

DROP TABLE [dbo].[T_TANULO];

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_T_TANULO]', N'T_TANULO';

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_constraint_PK_T_40251781]', N'PK_T_4025178', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4025259]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025178_4025259]
    ON [dbo].[T_TANULO]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_INGYENESTANKONVYELLATASA] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4025262]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025178_4025262]
    ON [dbo].[T_TANULO]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_MAGANTANULOSAGANAKOKA] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4025274]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025178_4025274]
    ON [dbo].[T_TANULO]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_TESTNEVELESTIPUSA] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4025344]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025178_4025344]
    ON [dbo].[T_TANULO]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_ETKEZESIKEDVEZMENY] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4025346]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025178_4025346]
    ON [dbo].[T_TANULO]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_HATRANYOSHELYZETU] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4025357]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025178_4025357]
    ON [dbo].[T_TANULO]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_VALLASA] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4025488]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025178_4025488]
    ON [dbo].[T_TANULO]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_ERTELMIFOGYATEKOS] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4025493]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025178_4025493]
    ON [dbo].[T_TANULO]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_HALLASSERULT] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4025495]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025178_4025495]
    ON [dbo].[T_TANULO]([C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC, [C_LATASSERULT] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4027540]...';


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


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4027541]...';


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


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4027542]...';


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


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025178_4027543]...';


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


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4025416_4025415]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025416_4025415]
    ON [dbo].[T_TANULO]([C_TANTERVID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_4026237_4026236]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4026237_4026236]
    ON [dbo].[T_TANULO]([C_FELVETELTANEVEID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_402517802_402517800]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402517802_402517800]
    ON [dbo].[T_TANULO]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULO].[I_T_402517805_402517803]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402517805_402517803]
    ON [dbo].[T_TANULO]([C_ALTANEVID] ASC);


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


GO
ALTER TABLE [dbo].[T_FELHASZNALOBELEPES] WITH NOCHECK
    ADD CONSTRAINT [FK_4025031_4025029] FOREIGN KEY ([C_FELHASZNALOID]) REFERENCES [dbo].[T_FELHASZNALO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_FELHASZNALOBELEPES] WITH NOCHECK
    ADD CONSTRAINT [FK_4025187_4025186] FOREIGN KEY ([C_GONDVISELOID]) REFERENCES [dbo].[T_GONDVISELO] ([ID]);


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_TANULOERTEKELES] WITH NOCHECK
    ADD CONSTRAINT [FK_4025938_4025937] FOREIGN KEY ([C_TANORAID]) REFERENCES [dbo].[T_TANITASIORA] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] WITH NOCHECK
    ADD CONSTRAINT [FK_4025602_4025601] FOREIGN KEY ([C_TANMENETID]) REFERENCES [dbo].[T_TANMENET] ([ID]);


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


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


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] WITH NOCHECK
    ADD CONSTRAINT [FK_4025611_4025610] FOREIGN KEY ([C_NAPTARINAPID]) REFERENCES [dbo].[T_NAPTARINAP] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] WITH NOCHECK
    ADD CONSTRAINT [FK_4025620_4025619] FOREIGN KEY ([C_ORARENDIORAID]) REFERENCES [dbo].[T_ORARENDIORA] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] WITH NOCHECK
    ADD CONSTRAINT [FK_4025623_4025622] FOREIGN KEY ([C_FOGLALKOZASID]) REFERENCES [dbo].[T_FOGLALKOZAS] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] WITH NOCHECK
    ADD CONSTRAINT [FK_4025629_4025628] FOREIGN KEY ([C_HELYETTESITOTANARID]) REFERENCES [dbo].[T_ALKALMAZOTT] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] WITH NOCHECK
    ADD CONSTRAINT [FK_4025635_4025634] FOREIGN KEY ([C_TEREMID]) REFERENCES [dbo].[T_TEREM] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] WITH NOCHECK
    ADD CONSTRAINT [FK_4025638_4025637] FOREIGN KEY ([C_OSZTALYCSOPORTID]) REFERENCES [dbo].[T_OSZTALYCSOPORT] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] WITH NOCHECK
    ADD CONSTRAINT [FK_4026315_4026314] FOREIGN KEY ([C_ORATULAJDONOSID]) REFERENCES [dbo].[T_FELHASZNALO] ([ID]);


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] WITH NOCHECK
    ADD CONSTRAINT [FK_4025575_4025580] FOREIGN KEY ([C_HELYETTESITESTIPUSA], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_HELYETTESITESTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] WITH NOCHECK
    ADD CONSTRAINT [FK_4025575_4025581] FOREIGN KEY ([C_HETNAPJA], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_HETNAPJATIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_ORALATOGATAS] WITH NOCHECK
    ADD CONSTRAINT [FK_4025795_4025794] FOREIGN KEY ([C_MEGTARTOTTORAID]) REFERENCES [dbo].[T_TANITASIORA] ([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_4025632_4025631]...';


GO
ALTER TABLE [dbo].[T_ORAK_TANAROK] WITH NOCHECK
    ADD CONSTRAINT [FK_4025632_4025631] FOREIGN KEY ([C_ORAKID]) REFERENCES [dbo].[T_TANITASIORA] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOMULASZTAS] WITH NOCHECK
    ADD CONSTRAINT [FK_4025674_4025672] FOREIGN KEY ([C_TANITASIORAKID]) REFERENCES [dbo].[T_TANITASIORA] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANITASIORA] WITH NOCHECK
    ADD CONSTRAINT [FK_4027901_4027900] FOREIGN KEY ([C_UPLOADEDFILEID]) REFERENCES [dbo].[T_UPLOADEDFILE] ([ID]);


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


GO
ALTER TABLE [dbo].[T_GONDVISELO] WITH NOCHECK
    ADD CONSTRAINT [FK_4025181_4025180] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOERTEKELES] WITH NOCHECK
    ADD CONSTRAINT [FK_4025665_4025663] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOESLADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4026674_4026673] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOTARGYMULASZTASSTATISZT] WITH NOCHECK
    ADD CONSTRAINT [FK_4026076_4026075] FOREIGN KEY ([C_TANULOMULASZTASSTATISZTIKAII]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOMULASZTASSTATISZTIKA] WITH NOCHECK
    ADD CONSTRAINT [FK_4026073_4026072] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOMENTESSEG] WITH NOCHECK
    ADD CONSTRAINT [FK_4025780_4025778] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOCSOPORT] WITH NOCHECK
    ADD CONSTRAINT [FK_4025527_4025525] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_IGAZOLAS] WITH NOCHECK
    ADD CONSTRAINT [FK_4025758_4025756] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_ERETTSEGIEREDMENY] WITH NOCHECK
    ADD CONSTRAINT [FK_4027621_4027620] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_DIAKIGAZOLVANYIGENYLES] WITH NOCHECK
    ADD CONSTRAINT [FK_4025788_4025787] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOKOZOSSEGISZOLGALAT] WITH NOCHECK
    ADD CONSTRAINT [FK_4026179_4026177] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_T_8935_4025190] FOREIGN KEY ([ID]) REFERENCES [dbo].[T_FELHASZNALO] ([ID]);


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


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


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_4026237_4026236] FOREIGN KEY ([C_FELVETELTANEVEID]) REFERENCES [dbo].[T_TANEV] ([ID]);


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_4025178_4025259] FOREIGN KEY ([C_INGYENESTANKONVYELLATASA], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_INGYENESTANKONYVELLATAS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_4025178_4025262] FOREIGN KEY ([C_MAGANTANULOSAGANAKOKA], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_MAGANTANULOSAGOKA] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_4025178_4025274] FOREIGN KEY ([C_TESTNEVELESTIPUSA], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_TESTNEVELESTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_4025178_4025344] FOREIGN KEY ([C_ETKEZESIKEDVEZMENY], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_ETKEZESIKEDVEZMENYTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_4025178_4025346] FOREIGN KEY ([C_HATRANYOSHELYZETU], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_HATRANYOSHELYZETTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_4025178_4025357] FOREIGN KEY ([C_VALLASA], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_VALLAS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_4025178_4025488] FOREIGN KEY ([C_ERTELMIFOGYATEKOS], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_ERTELMIFOGYATEKOSTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_4025178_4025493] FOREIGN KEY ([C_HALLASSERULT], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_HALLASSERULTTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULO] WITH NOCHECK
    ADD CONSTRAINT [FK_4025178_4025495] FOREIGN KEY ([C_LATASSERULT], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_LATASSERULTTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_TANULO_TANULOESEMENY] WITH NOCHECK
    ADD CONSTRAINT [FK_4025711_4025710] FOREIGN KEY ([C_TANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOMULASZTAS] WITH NOCHECK
    ADD CONSTRAINT [FK_4025673_4025672] FOREIGN KEY ([C_ORATANULOIID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


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


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_FELHASZNALOBELEPES] WITH CHECK CHECK CONSTRAINT [FK_4025031_4025029];

ALTER TABLE [dbo].[T_FELHASZNALOBELEPES] WITH CHECK CHECK CONSTRAINT [FK_4025187_4025186];

ALTER TABLE [dbo].[T_FELHASZNALOBELEPES] WITH CHECK CHECK CONSTRAINT [FK_402502202_402502200];

ALTER TABLE [dbo].[T_FELHASZNALOBELEPES] WITH CHECK CHECK CONSTRAINT [FK_402502205_402502203];

ALTER TABLE [dbo].[T_TANULOERTEKELES] WITH CHECK CHECK CONSTRAINT [FK_4025938_4025937];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4025602_4025601];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4025608_4025607];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4025611_4025610];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4025620_4025619];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4025623_4025622];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4025629_4025628];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4025635_4025634];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4025638_4025637];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4026315_4026314];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_402557502_402557500];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_402557505_402557503];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4025575_4025580];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4025575_4025581];

ALTER TABLE [dbo].[T_ORALATOGATAS] WITH CHECK CHECK CONSTRAINT [FK_4025795_4025794];

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

ALTER TABLE [dbo].[T_ORAK_TANAROK] WITH CHECK CHECK CONSTRAINT [FK_4025632_4025631];

ALTER TABLE [dbo].[T_TANULOMULASZTAS] WITH CHECK CHECK CONSTRAINT [FK_4025674_4025672];

ALTER TABLE [dbo].[T_TANITASIORA] WITH CHECK CHECK CONSTRAINT [FK_4027901_4027900];

ALTER TABLE [dbo].[T_GONDVISELO] WITH CHECK CHECK CONSTRAINT [FK_4025181_4025180];

ALTER TABLE [dbo].[T_TANULOERTEKELES] WITH CHECK CHECK CONSTRAINT [FK_4025665_4025663];

ALTER TABLE [dbo].[T_TANULOESLADATOK] WITH CHECK CHECK CONSTRAINT [FK_4026674_4026673];

ALTER TABLE [dbo].[T_TANULOTARGYMULASZTASSTATISZT] WITH CHECK CHECK CONSTRAINT [FK_4026076_4026075];

ALTER TABLE [dbo].[T_TANULOMULASZTASSTATISZTIKA] WITH CHECK CHECK CONSTRAINT [FK_4026073_4026072];

ALTER TABLE [dbo].[T_TANULOMENTESSEG] WITH CHECK CHECK CONSTRAINT [FK_4025780_4025778];

ALTER TABLE [dbo].[T_TANULOCSOPORT] WITH CHECK CHECK CONSTRAINT [FK_4025527_4025525];

ALTER TABLE [dbo].[T_IGAZOLAS] WITH CHECK CHECK CONSTRAINT [FK_4025758_4025756];

ALTER TABLE [dbo].[T_ERETTSEGIEREDMENY] WITH CHECK CHECK CONSTRAINT [FK_4027621_4027620];

ALTER TABLE [dbo].[T_DIAKIGAZOLVANYIGENYLES] WITH CHECK CHECK CONSTRAINT [FK_4025788_4025787];

ALTER TABLE [dbo].[T_TANULOKOZOSSEGISZOLGALAT] WITH CHECK CHECK CONSTRAINT [FK_4026179_4026177];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_T_8935_4025190];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025416_4025415];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4026237_4026236];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_402517802_402517800];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_402517805_402517803];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4025259];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4025262];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4025274];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4025344];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4025346];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4025357];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4025488];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4025493];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4025495];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4027540];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4027541];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4027542];

ALTER TABLE [dbo].[T_TANULO] WITH CHECK CHECK CONSTRAINT [FK_4025178_4027543];

ALTER TABLE [dbo].[T_TANULO_TANULOESEMENY] WITH CHECK CHECK CONSTRAINT [FK_4025711_4025710];

ALTER TABLE [dbo].[T_TANULOMULASZTAS] WITH CHECK CHECK CONSTRAINT [FK_4025673_4025672];


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_FELHASZNALOBELEPES', 'T_FELHASZNALOBELEPES_OSSZES',
  'T_TANULO', 'T_TANULO_OSSZES',
  'T_TANITASIORA', 'T_TANITASIORA_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


-- Triggerek inicializálás az összes táblára
DECLARE tableCursor CURSOR LOCAL FOR 
  SELECT DISTINCT TABLE_NAME
  FROM INFORMATION_SCHEMA.COLUMNS 
  WHERE COLUMN_NAME IN ('CREATOR', 'MODIFIER')
	AND TABLE_NAME NOT IN ('T_ENTITYHISTORY', 'T_ENTITYATTRIBUTEHISTORY', 'T_LOG', 'T_GLOBALLOCK', 'T_USERPROFILE', 'T_OLDALLATOGATOTTSAG')
	AND TABLE_NAME IN (
		SELECT t.name 
		FROM sys.tables t
		INNER JOIN sys.schemas s ON s.schema_id = t.schema_id
		WHERE s.name ='dbo' 
	)

DECLARE @table nvarchar(35)

OPEN tableCursor  
FETCH NEXT FROM tableCursor INTO @table  

WHILE @@FETCH_STATUS = 0 BEGIN  
  EXEC sp_Global_CreateTriggers @table
  FETCH NEXT FROM tableCursor INTO @table  
END  

CLOSE tableCursor  
DEALLOCATE tableCursor 


EXEC dev.sp_Global_GenerateAsyncAuditTriggerAll 1
GO

EXEC dev.sp_Global_GenerateAsyncAuditProcedureAll
GO

EXEC dev.sp_Global_GenerateAsyncAuditAuditPocessing
GO

ALTER QUEUE auditlog.AuditQueue WITH STATUS=OFF, ACTIVATION 
(STATUS = OFF)
GO

ALTER QUEUE auditlog.AuditQueue WITH STATUS=ON, ACTIVATION 
(STATUS = ON, MAX_QUEUE_READERS = 2)
GO
