﻿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_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_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_BESOROLASIFOKOZAT]           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_FOGLALKOZTATASTIPUS]         INT             NULL,
    [C_RESZMUNKAIDOSZAZALEK]        INT             DEFAULT ((100)) 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_BESOROLASIFOKOZAT], [C_KOTELEZOORASZAM], [C_MUNKAIDOKEDVEZMENYOKA], [C_MUNKAIDOKEDVEZMENYOKASZOVEG], [C_MUNKAIDOKEDVEZMENYORASZAM], [C_MUNKAKORTIPUSA], [C_MUNKAVISZONYTIPUSA], [C_NYUGDIJAS], [C_ISORAADO], [C_ALKALMAZOTTID], [C_FELADATELLATASIHELYID], [C_INTEZMENYID], [C_TANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR])
        SELECT   [ID],
                 [C_ALKALMAZASKEZDETE],
                 [C_ALKALMAZASMEGSZUNESE],
                 [C_BESOROLASIFOKOZAT],
                 [C_KOTELEZOORASZAM],
                 [C_MUNKAIDOKEDVEZMENYOKA],
                 [C_MUNKAIDOKEDVEZMENYOKASZOVEG],
                 [C_MUNKAIDOKEDVEZMENYORASZAM],
                 [C_MUNKAKORTIPUSA],
                 [C_MUNKAVISZONYTIPUSA],
                 [C_NYUGDIJAS],
                 [C_ISORAADO],
                 [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_BESOROLASIFOKOZAT] 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_4027558_4027632]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4027558_4027632]
    ON [dbo].[T_TOVABBIMUNKAUGYIADATOK]([C_INTEZMENYID] ASC, [C_TANEVID] ASC, [C_FOGLALKOZTATASTIPUS] 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_4027558_4027561]...';


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK] WITH NOCHECK
    ADD CONSTRAINT [FK_4027558_4027561] FOREIGN KEY ([C_BESOROLASIFOKOZAT], [C_INTEZMENYID], [C_TANEVID]) REFERENCES [dbo].[T_BESOROLASIFOKOZATTIPUS] ([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'Creating [dbo].[FK_4027558_4027632]...';


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


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_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];

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


GO
PRINT N'Update complete.';


GO
