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

SET NUMERIC_ROUNDABORT OFF;


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

GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

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

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

DROP TABLE [dbo].[T_MUNKAUGYIADATOK];

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

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

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
PRINT N'Starting rebuilding table [dbo].[T_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_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_KOTELEZOORASZAM], [C_MUNKAIDOKEDVEZMENYOKA], [C_MUNKAIDOKEDVEZMENYOKASZOVEG], [C_MUNKAIDOKEDVEZMENYORASZAM], [C_MUNKAKORTIPUSA], [C_MUNKAVISZONYTIPUSA], [C_NYUGDIJAS], [C_ISORAADO], [C_ALKALMAZOTTID], [C_BESOROLASIFOKOZAT], [C_FELADATELLATASIHELYID], [C_INTEZMENYID], [C_TANEVID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR])
        SELECT   [ID],
                 [C_ALKALMAZASKEZDETE],
                 [C_ALKALMAZASMEGSZUNESE],
                 [C_KOTELEZOORASZAM],
                 [C_MUNKAIDOKEDVEZMENYOKA],
                 [C_MUNKAIDOKEDVEZMENYOKASZOVEG],
                 [C_MUNKAIDOKEDVEZMENYORASZAM],
                 [C_MUNKAKORTIPUSA],
                 [C_MUNKAVISZONYTIPUSA],
                 [C_NYUGDIJAS],
                 [C_ISORAADO],
                 [C_ALKALMAZOTTID],
				 [C_KEPESITES],
                 [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_4027571_4027569]...';


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


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


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


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


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


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


GO
CREATE NONCLUSTERED INDEX [I_T_402755805_402755803]
    ON [dbo].[T_TOVABBIMUNKAUGYIADATOK]([C_TANEVID] ASC);


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
PRINT N'Creating [dbo].[FK_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'Refreshing [dbo].[T_MUNKAUGYIADATOK_OSSZES]...';


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


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


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[T_TOVABBIMUNKAUGYIADATOK_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_MUNKAUGYIADATOK] WITH CHECK CHECK CONSTRAINT [FK_4026116_4026121];

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


GO
PRINT N'Update complete.';


GO

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

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

DECLARE semaviewk CURSOR LOCAL FOR 
  SELECT '['+TABLE_SCHEMA + '].[' + TABLE_NAME + ']', TABLE_NAME
  FROM INFORMATION_SCHEMA.TABLES
  WHERE TABLE_TYPE = 'VIEW' and TABLE_SCHEMA LIKE 'KR[_]%[_]Schema'
  AND TABLE_NAME in (
  'T_MUNKAUGYIADATOK', 'T_MUNKAUGYIADATOK_OSSZES',
  'T_TOVABBIMUNKAUGYIADATOK', 'T_TOVABBIMUNKAUGYIADATOK_OSSZES'
  ) -- 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