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


GO
CREATE TABLE [dbo].[T_SZOVEGESERTEKELESEK] (
    [ID]              INT      NOT NULL,
    [C_ALINTEZMENYID] INT      NOT NULL,
    [C_ALTANEVID]     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_4027626] PRIMARY KEY CLUSTERED ([ID] ASC, [C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC)
);


GO
PRINT N'Creating [dbo].[T_SZOVEGESERTEKELESEK].[I_T_402762602_402762600]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402762602_402762600]
    ON [dbo].[T_SZOVEGESERTEKELESEK]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_SZOVEGESERTEKELESEK].[I_T_402762605_402762603]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402762605_402762603]
    ON [dbo].[T_SZOVEGESERTEKELESEK]([C_ALTANEVID] ASC);


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_SZOVEGESERTEKELESEK] WITH NOCHECK
    ADD CONSTRAINT [FK_T_21038_4027627] FOREIGN KEY ([ID], [C_ALINTEZMENYID], [C_ALTANEVID]) REFERENCES [dbo].[T_DICTIONARYITEMBASE] ([ID], [C_INTEZMENYID], [C_TANEVID]);


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


GO
ALTER TABLE [dbo].[T_SZOVEGESERTEKELESEK] WITH NOCHECK
    ADD CONSTRAINT [FK_402762602_402762600] FOREIGN KEY ([C_ALINTEZMENYID]) REFERENCES [dbo].[T_INTEZMENY] ([ID]);


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


GO
ALTER TABLE [dbo].[T_SZOVEGESERTEKELESEK] WITH NOCHECK
    ADD CONSTRAINT [FK_402762605_402762603] FOREIGN KEY ([C_ALTANEVID]) 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_SZOVEGESERTEKELESEK] WITH CHECK CHECK CONSTRAINT [FK_T_21038_4027627];

ALTER TABLE [dbo].[T_SZOVEGESERTEKELESEK] WITH CHECK CHECK CONSTRAINT [FK_402762602_402762600];

ALTER TABLE [dbo].[T_SZOVEGESERTEKELESEK] WITH CHECK CHECK CONSTRAINT [FK_402762605_402762603];


GO
PRINT N'Update complete.';


GO
