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


GO
CREATE TABLE [dbo].[T_AMIFOTARGY] (
    [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_4028865] PRIMARY KEY CLUSTERED ([ID] ASC, [C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC)
);


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[I_T_402886502_402886500]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402886502_402886500]
    ON [dbo].[T_AMIFOTARGY]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[I_T_402886505_402886503]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402886505_402886503]
    ON [dbo].[T_AMIFOTARGY]([C_ALTANEVID] ASC);


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


GO
CREATE TABLE [dbo].[T_AMITAGOZAT] (
    [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_4028863] PRIMARY KEY CLUSTERED ([ID] ASC, [C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC)
);


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[I_T_402886302_402886300]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402886302_402886300]
    ON [dbo].[T_AMITAGOZAT]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[I_T_402886305_402886303]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402886305_402886303]
    ON [dbo].[T_AMITAGOZAT]([C_ALTANEVID] ASC);


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


GO
CREATE TABLE [dbo].[T_AMITANTARGYKOTELEZOSEG] (
    [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_4028864] PRIMARY KEY CLUSTERED ([ID] ASC, [C_ALINTEZMENYID] ASC, [C_ALTANEVID] ASC)
);


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[I_T_402886402_402886400]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402886402_402886400]
    ON [dbo].[T_AMITANTARGYKOTELEZOSEG]([C_ALINTEZMENYID] ASC);


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[I_T_402886405_402886403]...';


GO
CREATE NONCLUSTERED INDEX [I_T_402886405_402886403]
    ON [dbo].[T_AMITANTARGYKOTELEZOSEG]([C_ALTANEVID] ASC);


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


GO
CREATE VIEW [dbo].T_AMIFOTARGY_OSSZES
        AS
        SELECT *
        FROM dbo.T_AMIFOTARGY
GO
PRINT N'Creating [dbo].[T_AMITAGOZAT_OSSZES]...';


GO
CREATE VIEW [dbo].T_AMITAGOZAT_OSSZES
        AS
        SELECT *
        FROM dbo.T_AMITAGOZAT
GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG_OSSZES]...';


GO
CREATE VIEW [dbo].T_AMITANTARGYKOTELEZOSEG_OSSZES
        AS
        SELECT *
        FROM dbo.T_AMITANTARGYKOTELEZOSEG
GO
PRINT N'Altering [dbo].[T_SZAMONKERESELOREJELZES].[C_SZAMONKERESMODID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A számonkérés összekötése az értékelés módokkal', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_SZAMONKERESELOREJELZES', @level2type = N'COLUMN', @level2name = N'C_SZAMONKERESMODID';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[ID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord egyedi azonosítója, generált IDENTITY(1, 1) (kivéve altáblák esetén, ahol a főtábla ID-ját kapja)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'ID';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[C_ALINTEZMENYID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Az intézmény ID-ja, amihez a rekord tartozik (altábla esetén)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'C_ALINTEZMENYID';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[C_ALTANEVID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A tanév ID-ja, amihez a rekord tartozik (altábla esetén)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'C_ALTANEVID';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[TOROLT].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord logikai töröltségét jelző flag', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'TOROLT';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[SERIAL].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Minden C# kódból történő módosítás esetén eggyel nő az értéke. Hogy párhuzamos módosítás esetnán ne íródjanak felül az adatok', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'SERIAL';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[LASTCHANGED].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'	A rekord utolsó módosításának időpontja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'LASTCHANGED';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[CREATED].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord létrehozásának időpontja ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'CREATED';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[MODIFIER].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekordot utoljára módosító felhasználó ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'MODIFIER';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[CREATOR].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekordot létrehozó felhasználó ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'CREATOR';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[ELOZOTANEVIREKORDID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord előző tanévben lévő ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'ELOZOTANEVIREKORDID';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[ELOZOTANEVIREKORDIDA].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord előző tanévben lévő ID-ja (altábla esetén) ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'ELOZOTANEVIREKORDIDA';


GO
PRINT N'Creating [dbo].[T_AMIFOTARGY].[NNID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord régi, Neptun Naplóban lévő ID-ja. (migrációval került be)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMIFOTARGY', @level2type = N'COLUMN', @level2name = N'NNID';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[ID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord egyedi azonosítója, generált IDENTITY(1, 1) (kivéve altáblák esetén, ahol a főtábla ID-ját kapja)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'ID';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[C_ALINTEZMENYID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Az intézmény ID-ja, amihez a rekord tartozik (altábla esetén)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'C_ALINTEZMENYID';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[C_ALTANEVID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A tanév ID-ja, amihez a rekord tartozik (altábla esetén)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'C_ALTANEVID';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[TOROLT].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord logikai töröltségét jelző flag', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'TOROLT';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[SERIAL].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Minden C# kódból történő módosítás esetén eggyel nő az értéke. Hogy párhuzamos módosítás esetnán ne íródjanak felül az adatok', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'SERIAL';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[LASTCHANGED].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'	A rekord utolsó módosításának időpontja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'LASTCHANGED';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[CREATED].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord létrehozásának időpontja ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'CREATED';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[MODIFIER].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekordot utoljára módosító felhasználó ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'MODIFIER';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[CREATOR].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekordot létrehozó felhasználó ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'CREATOR';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[ELOZOTANEVIREKORDID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord előző tanévben lévő ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'ELOZOTANEVIREKORDID';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[ELOZOTANEVIREKORDIDA].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord előző tanévben lévő ID-ja (altábla esetén) ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'ELOZOTANEVIREKORDIDA';


GO
PRINT N'Creating [dbo].[T_AMITAGOZAT].[NNID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord régi, Neptun Naplóban lévő ID-ja. (migrációval került be)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITAGOZAT', @level2type = N'COLUMN', @level2name = N'NNID';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[ID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord egyedi azonosítója, generált IDENTITY(1, 1) (kivéve altáblák esetén, ahol a főtábla ID-ját kapja)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'ID';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[C_ALINTEZMENYID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Az intézmény ID-ja, amihez a rekord tartozik (altábla esetén)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'C_ALINTEZMENYID';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[C_ALTANEVID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A tanév ID-ja, amihez a rekord tartozik (altábla esetén)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'C_ALTANEVID';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[TOROLT].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord logikai töröltségét jelző flag', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'TOROLT';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[SERIAL].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'Minden C# kódból történő módosítás esetén eggyel nő az értéke. Hogy párhuzamos módosítás esetnán ne íródjanak felül az adatok', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'SERIAL';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[LASTCHANGED].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'	A rekord utolsó módosításának időpontja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'LASTCHANGED';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[CREATED].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord létrehozásának időpontja ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'CREATED';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[MODIFIER].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekordot utoljára módosító felhasználó ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'MODIFIER';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[CREATOR].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekordot létrehozó felhasználó ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'CREATOR';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[ELOZOTANEVIREKORDID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord előző tanévben lévő ID-ja', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'ELOZOTANEVIREKORDID';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[ELOZOTANEVIREKORDIDA].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord előző tanévben lévő ID-ja (altábla esetén) ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'ELOZOTANEVIREKORDIDA';


GO
PRINT N'Creating [dbo].[T_AMITANTARGYKOTELEZOSEG].[NNID].[MS_Description]...';


GO
EXECUTE dev.uspAddOrUpdateExtendedProperty @name = N'MS_Description', @value = N'A rekord régi, Neptun Naplóban lévő ID-ja. (migrációval került be)', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_AMITANTARGYKOTELEZOSEG', @level2type = N'COLUMN', @level2name = N'NNID';


GO
PRINT N'Checking existing data against newly created constraints';



GO
ALTER TABLE [dbo].[T_AMIFOTARGY] WITH CHECK CHECK CONSTRAINT [FK_T_21038_4028866];

ALTER TABLE [dbo].[T_AMIFOTARGY] WITH CHECK CHECK CONSTRAINT [FK_402886502_402886500];

ALTER TABLE [dbo].[T_AMIFOTARGY] WITH CHECK CHECK CONSTRAINT [FK_402886505_402886503];

ALTER TABLE [dbo].[T_AMITAGOZAT] WITH CHECK CHECK CONSTRAINT [FK_T_21038_4028867];

ALTER TABLE [dbo].[T_AMITAGOZAT] WITH CHECK CHECK CONSTRAINT [FK_402886302_402886300];

ALTER TABLE [dbo].[T_AMITAGOZAT] WITH CHECK CHECK CONSTRAINT [FK_402886305_402886303];

ALTER TABLE [dbo].[T_AMITANTARGYKOTELEZOSEG] WITH CHECK CHECK CONSTRAINT [FK_T_21038_4028868];

ALTER TABLE [dbo].[T_AMITANTARGYKOTELEZOSEG] WITH CHECK CHECK CONSTRAINT [FK_402886402_402886400];

ALTER TABLE [dbo].[T_AMITANTARGYKOTELEZOSEG] WITH CHECK CHECK CONSTRAINT [FK_402886405_402886403];


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_SZAMONKERESELOREJELZES', 'T_SZAMONKERESELOREJELZES_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

--------------------

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