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


GO
ALTER TABLE [dbo].[T_EMAIL] DROP CONSTRAINT [FK_4025224_4025222];


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


GO
ALTER TABLE [dbo].[T_EMAIL] DROP CONSTRAINT [FK_4025239_4025237];


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


GO
ALTER TABLE [dbo].[T_EMAIL] DROP CONSTRAINT [FK_987602_987600];


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


GO
ALTER TABLE [dbo].[T_EMAIL] DROP CONSTRAINT [FK_987605_987603];


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


GO
ALTER TABLE [dbo].[T_EMAIL] DROP CONSTRAINT [FK_9876_24312];


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_OSZTALYZATERTEKELES] DROP CONSTRAINT [FK_T_4025641_4025742];


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


GO
ALTER TABLE [dbo].[T_OSZTALYFONOKIERTEKELES] DROP CONSTRAINT [FK_T_4025641_4025743];


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


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


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


GO
ALTER TABLE [dbo].[T_TELEFON] DROP CONSTRAINT [FK_20775_24305];


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


GO
ALTER TABLE [dbo].[T_TELEFON] DROP CONSTRAINT [FK_4025221_4025219];


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


GO
ALTER TABLE [dbo].[T_TELEFON] DROP CONSTRAINT [FK_4025236_4025234];


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


GO
ALTER TABLE [dbo].[T_TELEFON] DROP CONSTRAINT [FK_2077502_2077500];


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


GO
ALTER TABLE [dbo].[T_TELEFON] DROP CONSTRAINT [FK_2077505_2077503];


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


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [dbo].[tmp_ms_xx_T_EMAIL] (
    [ID]                  INT            IDENTITY (1, 1) NOT NULL,
    [C_EMAILTIPUSA]       INT            NULL,
    [C_EMAILCIM]          NVARCHAR (200) NOT NULL,
    [C_ALAPERTELMEZETT]   CHAR (1)       DEFAULT ('T') NOT NULL,
    [C_PUBLIKUSEMAILCIM]  NVARCHAR (200) NULL,
    [C_GONDVISELOID]      INT            NULL,
    [C_FELHASZNALOID]     INT            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_98761] PRIMARY KEY CLUSTERED ([ID] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [dbo].[T_EMAIL])
    BEGIN
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_EMAIL] ON;
        INSERT INTO [dbo].[tmp_ms_xx_T_EMAIL] ([ID], [C_EMAILTIPUSA], [C_EMAILCIM], [C_ALAPERTELMEZETT], [C_GONDVISELOID], [C_FELHASZNALOID], [C_INTEZMENYID], [C_TANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR], [ELOZOTANEVIREKORDID], [NNID])
        SELECT   [ID],
                 [C_EMAILTIPUSA],
                 [C_EMAILCIM],
                 [C_ALAPERTELMEZETT],
                 [C_GONDVISELOID],
                 [C_FELHASZNALOID],
                 [C_INTEZMENYID],
                 [C_TANEVID],
                 [TOROLT],
                 [SERIAL],
                 [LASTCHANGED],
                 [CREATED],
                 [MODIFIER],
                 [CREATOR],
                 [ELOZOTANEVIREKORDID],
                 [NNID]
        FROM     [dbo].[T_EMAIL]
        ORDER BY [ID] ASC;
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_EMAIL] OFF;
    END

DROP TABLE [dbo].[T_EMAIL];

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_T_EMAIL]', N'T_EMAIL';

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_constraint_PK_T_98761]', N'PK_T_9876', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Creating [dbo].[T_EMAIL].[I_T_9876_24312]...';


GO
CREATE NONCLUSTERED INDEX [I_T_9876_24312]
    ON [dbo].[T_EMAIL]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_EMAILTIPUSA] ASC);


GO
PRINT N'Creating [dbo].[T_EMAIL].[I_T_37640]...';


GO
CREATE NONCLUSTERED INDEX [I_T_37640]
    ON [dbo].[T_EMAIL]([C_EMAILCIM] ASC);


GO
PRINT N'Creating [dbo].[T_EMAIL].[I_T_4025224_4025222]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025224_4025222]
    ON [dbo].[T_EMAIL]([C_GONDVISELOID] ASC);


GO
PRINT N'Creating [dbo].[T_EMAIL].[I_T_4025239_4025237]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025239_4025237]
    ON [dbo].[T_EMAIL]([C_FELHASZNALOID] ASC);


GO
PRINT N'Creating [dbo].[T_EMAIL].[I_T_987602_987600]...';


GO
CREATE NONCLUSTERED INDEX [I_T_987602_987600]
    ON [dbo].[T_EMAIL]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_EMAIL].[I_T_987605_987603]...';


GO
CREATE NONCLUSTERED INDEX [I_T_987605_987603]
    ON [dbo].[T_EMAIL]([C_TANEVID] ASC);


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


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [dbo].[tmp_ms_xx_T_TANULOERTEKELES] (
    [ID]                  INT            IDENTITY (1, 1) NOT NULL,
    [C_ERTEKELESDATUM]    DATETIME       NOT NULL,
    [C_ERTEKELESTIPUSA]   INT            NOT NULL,
    [C_ERTEKELESSZOVEG]   NVARCHAR (MAX) NULL,
    [C_NEMMEGIRTDOLGOZAT] CHAR (1)       NULL,
    [C_ROGZITESDATUM]     DATETIME       NOT NULL,
    [C_OSZTALYZAT]        INT            NULL,
    [C_LATTAMOZAS]        CHAR (1)       DEFAULT ('F') NULL,
    [C_TANTARGYID]        INT            NULL,
    [C_TANULOID]          INT            NOT NULL,
    [C_OSZTALYCSOPORTID]  INT            NULL,
    [C_ERTEKELOID]        INT            NOT NULL,
    [C_TANORAID]          INT            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_40256411] PRIMARY KEY CLUSTERED ([ID] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [dbo].[T_TANULOERTEKELES])
    BEGIN
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_TANULOERTEKELES] ON;
        INSERT INTO [dbo].[tmp_ms_xx_T_TANULOERTEKELES] ([ID], [C_ERTEKELESDATUM], [C_ERTEKELESTIPUSA], [C_ERTEKELESSZOVEG], [C_NEMMEGIRTDOLGOZAT], [C_ROGZITESDATUM], [C_OSZTALYZAT], [C_TANTARGYID], [C_TANULOID], [C_OSZTALYCSOPORTID], [C_ERTEKELOID], [C_TANORAID], [C_INTEZMENYID], [C_TANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR], [ELOZOTANEVIREKORDID], [NNID])
        SELECT   [ID],
                 [C_ERTEKELESDATUM],
                 [C_ERTEKELESTIPUSA],
                 [C_ERTEKELESSZOVEG],
                 [C_NEMMEGIRTDOLGOZAT],
                 [C_ROGZITESDATUM],
                 [C_OSZTALYZAT],
                 [C_TANTARGYID],
                 [C_TANULOID],
                 [C_OSZTALYCSOPORTID],
                 [C_ERTEKELOID],
                 [C_TANORAID],
                 [C_INTEZMENYID],
                 [C_TANEVID],
                 [TOROLT],
                 [SERIAL],
                 [LASTCHANGED],
                 [CREATED],
                 [MODIFIER],
                 [CREATOR],
                 [ELOZOTANEVIREKORDID],
                 [NNID]
        FROM     [dbo].[T_TANULOERTEKELES]
        ORDER BY [ID] ASC;
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_TANULOERTEKELES] OFF;
    END

DROP TABLE [dbo].[T_TANULOERTEKELES];

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_T_TANULOERTEKELES]', N'T_TANULOERTEKELES';

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_constraint_PK_T_40256411]', N'PK_T_4025641', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELES].[I_T_4025641_4025644]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025641_4025644]
    ON [dbo].[T_TANULOERTEKELES]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_ERTEKELESTIPUSA] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELES].[I_T_4025641_4026317]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025641_4026317]
    ON [dbo].[T_TANULOERTEKELES]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_OSZTALYZAT] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELES].[I_T_4025662_4025660]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025662_4025660]
    ON [dbo].[T_TANULOERTEKELES]([C_TANTARGYID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELES].[I_T_4025665_4025663]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025665_4025663]
    ON [dbo].[T_TANULOERTEKELES]([C_TANULOID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELES].[I_T_4025668_4025666]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025668_4025666]
    ON [dbo].[T_TANULOERTEKELES]([C_OSZTALYCSOPORTID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELES].[I_T_4025670_4025669]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025670_4025669]
    ON [dbo].[T_TANULOERTEKELES]([C_ERTEKELOID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELES].[I_T_4025938_4025937]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025938_4025937]
    ON [dbo].[T_TANULOERTEKELES]([C_TANORAID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELES].[I_T_402564102_402564100]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402564102_402564100]
    ON [dbo].[T_TANULOERTEKELES]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELES].[I_T_402564105_402564103]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402564105_402564103]
    ON [dbo].[T_TANULOERTEKELES]([C_TANEVID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELES].[IDX_TANULOERTEKELES_TANULOID_TANTARGYID_ERTEKELESTIPUSA]...';


GO
CREATE NONCLUSTERED INDEX [IDX_TANULOERTEKELES_TANULOID_TANTARGYID_ERTEKELESTIPUSA]
    ON [dbo].[T_TANULOERTEKELES]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_TANULOID] ASC, [C_TANTARGYID] ASC, [C_ERTEKELESTIPUSA] 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       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_LATTAMOZAS]          CHAR (1)       DEFAULT ('F') 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') 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_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], [ELOZOTANEVIREKORDID], [NNID])
        SELECT   [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],
                 [ELOZOTANEVIREKORDID],
                 [NNID]
        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_TELEFON]...';


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [dbo].[tmp_ms_xx_T_TELEFON] (
    [ID]                    INT            IDENTITY (1, 1) NOT NULL,
    [C_TELEFONTIPUSA]       INT            NOT NULL,
    [C_TELEFONSZAM]         NVARCHAR (100) NOT NULL,
    [C_LEIRAS]              NVARCHAR (50)  NULL,
    [C_ALAPERTELMEZETT]     CHAR (1)       DEFAULT ('F') NOT NULL,
    [C_PUBLIKUSTELEFONSZAM] NVARCHAR (100) NULL,
    [C_GONDVISELOID]        INT            NULL,
    [C_FELHASZNALOID]       INT            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_207751] PRIMARY KEY CLUSTERED ([ID] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [dbo].[T_TELEFON])
    BEGIN
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_TELEFON] ON;
        INSERT INTO [dbo].[tmp_ms_xx_T_TELEFON] ([ID], [C_TELEFONTIPUSA], [C_TELEFONSZAM], [C_LEIRAS], [C_ALAPERTELMEZETT], [C_GONDVISELOID], [C_FELHASZNALOID], [C_INTEZMENYID], [C_TANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR], [ELOZOTANEVIREKORDID], [NNID])
        SELECT   [ID],
                 [C_TELEFONTIPUSA],
                 [C_TELEFONSZAM],
                 [C_LEIRAS],
                 [C_ALAPERTELMEZETT],
                 [C_GONDVISELOID],
                 [C_FELHASZNALOID],
                 [C_INTEZMENYID],
                 [C_TANEVID],
                 [TOROLT],
                 [SERIAL],
                 [LASTCHANGED],
                 [CREATED],
                 [MODIFIER],
                 [CREATOR],
                 [ELOZOTANEVIREKORDID],
                 [NNID]
        FROM     [dbo].[T_TELEFON]
        ORDER BY [ID] ASC;
        SET IDENTITY_INSERT [dbo].[tmp_ms_xx_T_TELEFON] OFF;
    END

DROP TABLE [dbo].[T_TELEFON];

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_T_TELEFON]', N'T_TELEFON';

EXECUTE sp_rename N'[dbo].[tmp_ms_xx_constraint_PK_T_207751]', N'PK_T_20775', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Creating [dbo].[T_TELEFON].[I_T_20775_24305]...';


GO
CREATE NONCLUSTERED INDEX [I_T_20775_24305]
    ON [dbo].[T_TELEFON]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_TELEFONTIPUSA] ASC);


GO
PRINT N'Creating [dbo].[T_TELEFON].[I_T_1546382]...';


GO
CREATE NONCLUSTERED INDEX [I_T_1546382]
    ON [dbo].[T_TELEFON]([C_TELEFONSZAM] ASC);


GO
PRINT N'Creating [dbo].[T_TELEFON].[I_T_4025221_4025219]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025221_4025219]
    ON [dbo].[T_TELEFON]([C_GONDVISELOID] ASC);


GO
PRINT N'Creating [dbo].[T_TELEFON].[I_T_4025236_4025234]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4025236_4025234]
    ON [dbo].[T_TELEFON]([C_FELHASZNALOID] ASC);


GO
PRINT N'Creating [dbo].[T_TELEFON].[I_T_2077502_2077500]...';


GO
CREATE NONCLUSTERED INDEX [I_T_2077502_2077500]
    ON [dbo].[T_TELEFON]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_TELEFON].[I_T_2077505_2077503]...';


GO
CREATE NONCLUSTERED INDEX [I_T_2077505_2077503]
    ON [dbo].[T_TELEFON]([C_TANEVID] ASC);


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_EMAIL] WITH NOCHECK
    ADD CONSTRAINT [FK_9876_24312] FOREIGN KEY ([C_EMAILTIPUSA], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_EMAILTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULOERTEKELES] WITH NOCHECK
    ADD CONSTRAINT [FK_4025641_4025644] FOREIGN KEY ([C_ERTEKELESTIPUSA], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_ERTEKELESTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULOERTEKELES] WITH NOCHECK
    ADD CONSTRAINT [FK_4025641_4026317] FOREIGN KEY ([C_OSZTALYZAT], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_OSZTALYZATTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


GO
ALTER TABLE [dbo].[T_TANULOERTEKELES] WITH NOCHECK
    ADD CONSTRAINT [FK_4025662_4025660] FOREIGN KEY ([C_TANTARGYID]) REFERENCES [dbo].[T_TANTARGY] ([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_4025668_4025666]...';


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


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


GO
ALTER TABLE [dbo].[T_TANULOERTEKELES] WITH NOCHECK
    ADD CONSTRAINT [FK_4025670_4025669] FOREIGN KEY ([C_ERTEKELOID]) REFERENCES [dbo].[T_ALKALMAZOTT] ([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_402564102_402564100]...';


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


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


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


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


GO
ALTER TABLE [dbo].[T_OSZTALYZATERTEKELES] WITH NOCHECK
    ADD CONSTRAINT [FK_T_4025641_4025742] FOREIGN KEY ([ID]) REFERENCES [dbo].[T_TANULOERTEKELES] ([ID]);


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


GO
ALTER TABLE [dbo].[T_OSZTALYFONOKIERTEKELES] WITH NOCHECK
    ADD CONSTRAINT [FK_T_4025641_4025743] FOREIGN KEY ([ID]) REFERENCES [dbo].[T_TANULOERTEKELES] ([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_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_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_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_20775_24305]...';


GO
ALTER TABLE [dbo].[T_TELEFON] WITH NOCHECK
    ADD CONSTRAINT [FK_20775_24305] FOREIGN KEY ([C_TELEFONTIPUSA], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_TELEFONTIPUS] ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]);


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_EMAIL] WITH CHECK CHECK CONSTRAINT [FK_4025224_4025222];

ALTER TABLE [dbo].[T_EMAIL] WITH CHECK CHECK CONSTRAINT [FK_4025239_4025237];

ALTER TABLE [dbo].[T_EMAIL] WITH CHECK CHECK CONSTRAINT [FK_987602_987600];

ALTER TABLE [dbo].[T_EMAIL] WITH CHECK CHECK CONSTRAINT [FK_987605_987603];

ALTER TABLE [dbo].[T_EMAIL] WITH CHECK CHECK CONSTRAINT [FK_9876_24312];

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

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

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

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

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

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

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

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

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

ALTER TABLE [dbo].[T_OSZTALYZATERTEKELES] WITH CHECK CHECK CONSTRAINT [FK_T_4025641_4025742];

ALTER TABLE [dbo].[T_OSZTALYFONOKIERTEKELES] WITH CHECK CHECK CONSTRAINT [FK_T_4025641_4025743];

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

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_OSZTALYCSOPORT_TANULOESEMENY] WITH CHECK CHECK CONSTRAINT [FK_4027557_4027555];

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

ALTER TABLE [dbo].[T_TELEFON] WITH CHECK CHECK CONSTRAINT [FK_20775_24305];

ALTER TABLE [dbo].[T_TELEFON] WITH CHECK CHECK CONSTRAINT [FK_4025221_4025219];

ALTER TABLE [dbo].[T_TELEFON] WITH CHECK CHECK CONSTRAINT [FK_4025236_4025234];

ALTER TABLE [dbo].[T_TELEFON] WITH CHECK CHECK CONSTRAINT [FK_2077502_2077500];

ALTER TABLE [dbo].[T_TELEFON] WITH CHECK CHECK CONSTRAINT [FK_2077505_2077503];


GO
PRINT N'Update complete.';


GO
