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


GO
CREATE TABLE [dbo].[T_ESLTANTARGYKATEGORIA] (
    [ID]                   INT      NOT NULL,
    [C_ALINTEZMENYID]      INT      NOT NULL,
    [C_ALTANEVID]          INT      NOT NULL,
    [TOROLT]               CHAR (1) NOT NULL,
    [SERIAL]               INT      NOT NULL,
    [LASTCHANGED]          DATETIME NOT NULL,
    [CREATED]              DATETIME NOT NULL,
    [MODIFIER]             INT      NULL,
    [CREATOR]              INT      NULL,
    [ELOZOTANEVIREKORDID]  INT      NULL,
    [ELOZOTANEVIREKORDIDA] INT      NULL,
    [NNID]                 INT      NULL,
    CONSTRAINT [PK_T_4028752] PRIMARY KEY CLUSTERED ([ID] ASC, [C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC)
);


GO
PRINT N'Creating [dbo].[T_ESLTANTARGYKATEGORIA].[I_T_402875202_402875200]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402875202_402875200]
    ON [dbo].[T_ESLTANTARGYKATEGORIA]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_ESLTANTARGYKATEGORIA].[I_T_402875205_402875203]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402875205_402875203]
    ON [dbo].[T_ESLTANTARGYKATEGORIA]([C_ALTANEVID] ASC);


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


GO
CREATE TABLE [dbo].[T_TAVOLLETSTATUSZ] (
    [ID]                   INT      NOT NULL,
    [C_ALINTEZMENYID]      INT      NOT NULL,
    [C_ALTANEVID]          INT      NOT NULL,
    [TOROLT]               CHAR (1) NOT NULL,
    [SERIAL]               INT      NOT NULL,
    [LASTCHANGED]          DATETIME NOT NULL,
    [CREATED]              DATETIME NOT NULL,
    [MODIFIER]             INT      NULL,
    [CREATOR]              INT      NULL,
    [ELOZOTANEVIREKORDID]  INT      NULL,
    [ELOZOTANEVIREKORDIDA] INT      NULL,
    [NNID]                 INT      NULL,
    CONSTRAINT [PK_T_4028750] PRIMARY KEY CLUSTERED ([ID] ASC, [C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC)
);


GO
PRINT N'Creating [dbo].[T_TAVOLLETSTATUSZ].[I_T_402875002_402875000]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402875002_402875000]
    ON [dbo].[T_TAVOLLETSTATUSZ]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_TAVOLLETSTATUSZ].[I_T_402875005_402875003]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402875005_402875003]
    ON [dbo].[T_TAVOLLETSTATUSZ]([C_ALTANEVID] ASC);


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


GO
CREATE TABLE [dbo].[T_TAVOLLETTIPUS] (
    [ID]                   INT      NOT NULL,
    [C_ALINTEZMENYID]      INT      NOT NULL,
    [C_ALTANEVID]          INT      NOT NULL,
    [TOROLT]               CHAR (1) NOT NULL,
    [SERIAL]               INT      NOT NULL,
    [LASTCHANGED]          DATETIME NOT NULL,
    [CREATED]              DATETIME NOT NULL,
    [MODIFIER]             INT      NULL,
    [CREATOR]              INT      NULL,
    [ELOZOTANEVIREKORDID]  INT      NULL,
    [ELOZOTANEVIREKORDIDA] INT      NULL,
    [NNID]                 INT      NULL,
    CONSTRAINT [PK_T_4028751] PRIMARY KEY CLUSTERED ([ID] ASC, [C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC)
);


GO
PRINT N'Creating [dbo].[T_TAVOLLETTIPUS].[I_T_402875102_402875100]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402875102_402875100]
    ON [dbo].[T_TAVOLLETTIPUS]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_TAVOLLETTIPUS].[I_T_402875105_402875103]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402875105_402875103]
    ON [dbo].[T_TAVOLLETTIPUS]([C_ALTANEVID] ASC);


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_ESLTANTARGYKATEGORIA]
    ADD DEFAULT ((0)) FOR [SERIAL];


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_TAVOLLETSTATUSZ]
    ADD DEFAULT ((0)) FOR [SERIAL];


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


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


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


GO
ALTER TABLE [dbo].[T_TAVOLLETTIPUS]
    ADD DEFAULT ((0)) FOR [SERIAL];


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


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


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


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


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_ESLTANTARGYKATEGORIA] WITH NOCHECK
    ADD CONSTRAINT [FK_402875205_402875203] FOREIGN KEY ([C_ALTANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_TAVOLLETSTATUSZ] WITH NOCHECK
    ADD CONSTRAINT [FK_402875005_402875003] FOREIGN KEY ([C_ALTANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


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


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


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


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


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


GO
ALTER TABLE [dbo].[T_TAVOLLETTIPUS] WITH NOCHECK
    ADD CONSTRAINT [FK_402875105_402875103] FOREIGN KEY ([C_ALTANEVID]) REFERENCES [dbo].[T_TANEV] ([ID]);


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


GO
CREATE VIEW [dbo].T_ESLTANTARGYKATEGORIA_OSSZES
        AS
        SELECT *
        FROM dbo.T_ESLTANTARGYKATEGORIA
GO
PRINT N'Creating [dbo].[T_TAVOLLETSTATUSZ_OSSZES]...';


GO
CREATE VIEW [dbo].T_TAVOLLETSTATUSZ_OSSZES
        AS
        SELECT *
        FROM dbo.T_TAVOLLETSTATUSZ
GO
PRINT N'Creating [dbo].[T_TAVOLLETTIPUS_OSSZES]...';


GO
CREATE VIEW [dbo].T_TAVOLLETTIPUS_OSSZES
        AS
        SELECT *
        FROM dbo.T_TAVOLLETTIPUS
GO
PRINT N'Checking existing data against newly created constraints';


GO
ALTER TABLE [dbo].[T_ESLTANTARGYKATEGORIA] WITH CHECK CHECK CONSTRAINT [FK_T_21038_4028753];

ALTER TABLE [dbo].[T_ESLTANTARGYKATEGORIA] WITH CHECK CHECK CONSTRAINT [FK_402875202_402875200];

ALTER TABLE [dbo].[T_ESLTANTARGYKATEGORIA] WITH CHECK CHECK CONSTRAINT [FK_402875205_402875203];

ALTER TABLE [dbo].[T_TAVOLLETSTATUSZ] WITH CHECK CHECK CONSTRAINT [FK_T_21038_4028754];

ALTER TABLE [dbo].[T_TAVOLLETSTATUSZ] WITH CHECK CHECK CONSTRAINT [FK_402875002_402875000];

ALTER TABLE [dbo].[T_TAVOLLETSTATUSZ] WITH CHECK CHECK CONSTRAINT [FK_402875005_402875003];

ALTER TABLE [dbo].[T_TAVOLLETTIPUS] WITH CHECK CHECK CONSTRAINT [FK_T_21038_4028755];

ALTER TABLE [dbo].[T_TAVOLLETTIPUS] WITH CHECK CHECK CONSTRAINT [FK_402875102_402875100];

ALTER TABLE [dbo].[T_TAVOLLETTIPUS] WITH CHECK CHECK CONSTRAINT [FK_402875105_402875103];


GO
PRINT N'Update complete.';


GO
--------------------

EXEC dev.sp_Global_GenerateAsyncAuditTriggerAll
GO


ALTER QUEUE auditLog.[AuditQueue]
WITH ACTIVATION
( 
    STATUS = ON,
    PROCEDURE_NAME = auditLog.usp_AuditProcessing,
    MAX_QUEUE_READERS = 10,
    EXECUTE AS 'Kreta_tech_user'
);

GO