﻿PRINT N'Dropping [dbo].[T_TANULOERTEKELESLATTAMOZAS].[I_T_4028060_4028058]...';


GO
DROP INDEX [I_T_4028060_4028058]
    ON [dbo].[T_TANULOERTEKELESLATTAMOZAS];


GO
PRINT N'Dropping [dbo].[T_TANULOESEMENYLATTAMOZAS].[I_T_4028056_4028055]...';


GO
DROP INDEX [I_T_4028056_4028055]
    ON [dbo].[T_TANULOESEMENYLATTAMOZAS];


GO
PRINT N'Dropping [dbo].[FK_4028060_4028058]...';


GO
ALTER TABLE [dbo].[T_TANULOERTEKELESLATTAMOZAS] DROP CONSTRAINT [FK_4028060_4028058];


GO
PRINT N'Dropping [dbo].[FK_4028056_4028055]...';


GO
ALTER TABLE [dbo].[T_TANULOESEMENYLATTAMOZAS] DROP CONSTRAINT [FK_4028056_4028055];


GO
PRINT N'Altering [dbo].[T_GONDVISELO]...';


GO
ALTER TABLE [dbo].[T_GONDVISELO]
    ADD [C_IMPORTALT] CHAR (1) DEFAULT ('F') NOT NULL;


GO
PRINT N'Altering [dbo].[T_TANULOERTEKELESLATTAMOZAS]...';


GO
ALTER TABLE [dbo].[T_TANULOERTEKELESLATTAMOZAS] ALTER COLUMN [C_GONDVISELOID] INT NULL;


GO
ALTER TABLE [dbo].[T_TANULOERTEKELESLATTAMOZAS]
    ADD [C_LATTAMOZOTANULOID] INT NULL;


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELESLATTAMOZAS].[I_T_4028060_4028058]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028060_4028058]
    ON [dbo].[T_TANULOERTEKELESLATTAMOZAS]([C_GONDVISELOID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOERTEKELESLATTAMOZAS].[I_T_4029111_4029109]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4029111_4029109]
    ON [dbo].[T_TANULOERTEKELESLATTAMOZAS]([C_LATTAMOZOTANULOID] ASC);


GO
PRINT N'Altering [dbo].[T_TANULOESEMENYLATTAMOZAS]...';


GO
ALTER TABLE [dbo].[T_TANULOESEMENYLATTAMOZAS] ALTER COLUMN [C_GONDVISELOID] INT NULL;


GO
ALTER TABLE [dbo].[T_TANULOESEMENYLATTAMOZAS]
    ADD [C_LATTAMOZOTANULOID] INT NULL;


GO
PRINT N'Creating [dbo].[T_TANULOESEMENYLATTAMOZAS].[I_T_4028056_4028055]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4028056_4028055]
    ON [dbo].[T_TANULOESEMENYLATTAMOZAS]([C_GONDVISELOID] ASC);


GO
PRINT N'Creating [dbo].[T_TANULOESEMENYLATTAMOZAS].[I_T_4029113_4029112]...';


GO
CREATE NONCLUSTERED INDEX [I_T_4029113_4029112]
    ON [dbo].[T_TANULOESEMENYLATTAMOZAS]([C_LATTAMOZOTANULOID] ASC);


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


GO
ALTER TABLE [dbo].[T_TANULOERTEKELESLATTAMOZAS] WITH NOCHECK
    ADD CONSTRAINT [FK_4028060_4028058] FOREIGN KEY ([C_GONDVISELOID]) REFERENCES [dbo].[T_GONDVISELO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENYLATTAMOZAS] WITH NOCHECK
    ADD CONSTRAINT [FK_4028056_4028055] FOREIGN KEY ([C_GONDVISELOID]) REFERENCES [dbo].[T_GONDVISELO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOERTEKELESLATTAMOZAS] WITH NOCHECK
    ADD CONSTRAINT [FK_4029111_4029109] FOREIGN KEY ([C_LATTAMOZOTANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


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


GO
ALTER TABLE [dbo].[T_TANULOESEMENYLATTAMOZAS] WITH NOCHECK
    ADD CONSTRAINT [FK_4029113_4029112] FOREIGN KEY ([C_LATTAMOZOTANULOID]) REFERENCES [dbo].[T_TANULO] ([ID]);


GO
PRINT N'Refreshing [dbo].[T_GONDVISELO_OSSZES]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[T_GONDVISELO_OSSZES]';


GO
PRINT N'Refreshing [dbo].[T_TANULOERTEKELESLATTAMOZAS_OSSZES]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[T_TANULOERTEKELESLATTAMOZAS_OSSZES]';


GO
PRINT N'Refreshing [dbo].[T_TANULOESEMENYLATTAMOZAS_OSSZES]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[T_TANULOESEMENYLATTAMOZAS_OSSZES]';


GO
PRINT N'Creating [dbo].[T_GONDVISELO].[C_IMPORTALT].[MS_Description]...';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Importálással került-e be a rekord. Amint felületen módosítják a rekordot a flag False-ra vált. ', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'T_GONDVISELO', @level2type = N'COLUMN', @level2name = N'C_IMPORTALT';


GO
PRINT N'Refreshing [dbo].[fnGetDokumentumGondviselok]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[fnGetDokumentumGondviselok]';


GO
PRINT N'Refreshing [dbo].[fnGetDokumentumTanuloOrGondviseloCim]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[fnGetDokumentumTanuloOrGondviseloCim]';


GO
PRINT N'Refreshing [dbo].[sp_GetTanulokhozTartozoGondviselok]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_GetTanulokhozTartozoGondviselok]';


GO
PRINT N'Refreshing [dbo].[sp_GetAdminDashboardNaplo]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_GetAdminDashboardNaplo]';


GO
PRINT N'Refreshing [dbo].[sp_GetHozzatartozok]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_GetHozzatartozok]';


GO
PRINT N'Refreshing [dbo].[uspDeleteInvalidLinks]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspDeleteInvalidLinks]';


GO
PRINT N'Refreshing [dbo].[sp_GetKozossegiJelentkezesLap]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_GetKozossegiJelentkezesLap]';


GO
PRINT N'Refreshing [dbo].[sp_AktivTanevValtasa]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_AktivTanevValtasa]';


GO
PRINT N'Refreshing [dbo].[sp_GetFelhasznaloBelepesGondviseloExportData]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_GetFelhasznaloBelepesGondviseloExportData]';


GO
PRINT N'Refreshing [dbo].[sp_GetNaplozasMulasztasList]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_GetNaplozasMulasztasList]';


GO
PRINT N'Refreshing [dbo].[sp_GetOsszesFelhasznaloBelepesData]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_GetOsszesFelhasznaloBelepesData]';


GO
PRINT N'Refreshing [dbo].[sp_GetTanuloGondviseloExportData]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_GetTanuloGondviseloExportData]';


GO
PRINT N'Refreshing [dbo].[sp_GetTanuloiGondviseloAdatok]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_GetTanuloiGondviseloAdatok]';


GO
PRINT N'Refreshing [dbo].[uspFollowUpGondviseloCim]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspFollowUpGondviseloCim]';


GO
PRINT N'Refreshing [dbo].[uspGetFelhasznaloBelepesData]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspGetFelhasznaloBelepesData]';


GO
PRINT N'Refreshing [dbo].[uspKIRstat_TanuloLakohely]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspKIRstat_TanuloLakohely]';


GO
PRINT N'Refreshing [dbo].[uspUpdateAllEgyediAzonosito]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspUpdateAllEgyediAzonosito]';


GO
PRINT N'Refreshing [dbo].[sp_GetTanuloiAdatlapAdatok]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_GetTanuloiAdatlapAdatok]';


GO
PRINT N'Refreshing [dbo].[uspGetTorzslap]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspGetTorzslap]';


GO
PRINT N'Refreshing [dbo].[sp_GetErtesitesAltEsMulAdatok]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_GetErtesitesAltEsMulAdatok]';


GO
PRINT N'Refreshing [dbo].[uspGetCsoportNaplo]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspGetCsoportNaplo]';


GO
PRINT N'Refreshing [dbo].[uspGetErtesitoNyomtatvany]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspGetErtesitoNyomtatvany]';


GO
PRINT N'Refreshing [dbo].[uspGetNapkozisNaplo]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspGetNapkozisNaplo]';


GO
PRINT N'Refreshing [dbo].[uspGetOsztalyNaplo]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspGetOsztalyNaplo]';


GO
PRINT N'Refreshing [dbo].[uspGetTanoranKivuliNaplo]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspGetTanoranKivuliNaplo]';


GO
PRINT N'Refreshing [dbo].[uspFollowUpGondviselo]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspFollowUpGondviselo]';


GO
PRINT N'Refreshing [dbo].[sp_ImportTanulokGondviseloi]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[sp_ImportTanulokGondviseloi]';


GO
PRINT N'Refreshing [dbo].[uspCloneTanulo]...';


GO
EXECUTE sp_refreshsqlmodule N'[dbo].[uspCloneTanulo]';


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


GO
ALTER TABLE [dbo].[T_TANULOERTEKELESLATTAMOZAS] WITH CHECK CHECK CONSTRAINT [FK_4028060_4028058];

ALTER TABLE [dbo].[T_TANULOESEMENYLATTAMOZAS] WITH CHECK CHECK CONSTRAINT [FK_4028056_4028055];

ALTER TABLE [dbo].[T_TANULOERTEKELESLATTAMOZAS] WITH CHECK CHECK CONSTRAINT [FK_4029111_4029109];

ALTER TABLE [dbo].[T_TANULOESEMENYLATTAMOZAS] WITH CHECK CHECK CONSTRAINT [FK_4029113_4029112];


GO
PRINT N'Update complete.';


GO
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_GONDVISELO', 'T_GONDVISELO_OSSZES',
   'T_TANULOERTEKELESLATTAMOZAS', 'T_TANULOERTEKELESLATTAMOZAS_OSSZES',
   'T_TANULOESEMENYLATTAMOZAS', 'T_TANULOESEMENYLATTAMOZAS_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
