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


GO
CREATE TABLE [dbo].[T_MUKODESIHELYADATSZOLGALTATAS] (
    [ID]                   INT            IDENTITY (1, 1) NOT NULL,
    [C_INFORMATIKAOKTATAS] CHAR (1)       NULL,
    [C_INTFELTOLTESSAV]    NVARCHAR (255) NULL,
    [C_INTHAVIDIJ]         INT            NULL,
    [C_INTLETOLTESSAV]     NVARCHAR (255) NULL,
    [C_INTSZOLGALTATO]     NVARCHAR (255) NULL,
    [C_MUKODESIHELYID]     INT            NOT 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_4027715] PRIMARY KEY CLUSTERED ([ID] ASC)
);


GO
PRINT N'Creating [dbo].[T_MUKODESIHELYADATSZOLGALTATAS].[I_T_4027722_4027721]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4027722_4027721]
    ON [dbo].[T_MUKODESIHELYADATSZOLGALTATAS]([C_MUKODESIHELYID] ASC);


GO
PRINT N'Creating [dbo].[T_MUKODESIHELYADATSZOLGALTATAS].[I_T_402771502_402771500]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402771502_402771500]
    ON [dbo].[T_MUKODESIHELYADATSZOLGALTATAS]([C_INTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_MUKODESIHELYADATSZOLGALTATAS].[I_T_402771505_402771503]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402771505_402771503]
    ON [dbo].[T_MUKODESIHELYADATSZOLGALTATAS]([C_TANEVID] ASC);


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_MUKODESIHELYADATSZOLGALTATAS] WITH NOCHECK
    ADD CONSTRAINT [FK_4027722_4027721] FOREIGN KEY ([C_MUKODESIHELYID]) REFERENCES [dbo].[T_MUKODESIHELY] ([ID]);


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


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


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


GO
ALTER TABLE [dbo].[T_MUKODESIHELYADATSZOLGALTATAS] WITH NOCHECK
    ADD CONSTRAINT [FK_402771505_402771503] 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_MUKODESIHELYADATSZOLGALTATAS] WITH CHECK CHECK CONSTRAINT [FK_4027722_4027721];

ALTER TABLE [dbo].[T_MUKODESIHELYADATSZOLGALTATAS] WITH CHECK CHECK CONSTRAINT [FK_402771502_402771500];

ALTER TABLE [dbo].[T_MUKODESIHELYADATSZOLGALTATAS] WITH CHECK CHECK CONSTRAINT [FK_402771505_402771503];


GO
PRINT N'Update complete.';


GO
