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

SET NUMERIC_ROUNDABORT OFF;


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
PRINT N'Creating unnamed constraint on [dbo].[T_TOVABBIMUNKAUGYIADATOK]...';


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK]
    ADD DEFAULT ('F') FOR [C_NYUGDIJAS];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_TOVABBIMUNKAUGYIADATOK]...';


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK]
    ADD DEFAULT ('F') FOR [TOROLT];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_TOVABBIMUNKAUGYIADATOK]...';


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK]
    ADD DEFAULT (getdate()) FOR [CREATED];


GO
PRINT N'Creating unnamed constraint on [dbo].[T_TOVABBIMUNKAUGYIADATOK]...';


GO
ALTER TABLE [dbo].[T_TOVABBIMUNKAUGYIADATOK]
    ADD DEFAULT (getdate()) FOR [LASTCHANGED];


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO


PRINT N'Refreshing [dbo].[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_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
