IF (COL_LENGTH('T_NEMKOTOTTMUNKAIDO', 'C_TULAJDONOSID') IS NOT NULL
    AND COL_LENGTH('T_NEMKOTOTTMUNKAIDO', 'C_TULAJDONOSID_BAK') IS NOT NULL)
BEGIN
    DISABLE TRIGGER tr_AsyncAuditNEMKOTOTTMUNKAIDO ON T_NEMKOTOTTMUNKAIDO;
    EXECUTE('UPDATE T_NEMKOTOTTMUNKAIDO SET C_TULAJDONOSID = C_TULAJDONOSID_BAK;');
    ENABLE TRIGGER tr_AsyncAuditNEMKOTOTTMUNKAIDO ON T_NEMKOTOTTMUNKAIDO;
    
END

IF (COL_LENGTH('T_ORARENDIORA', 'C_ORATULAJDONOSID') IS NOT NULL
    AND COL_LENGTH('T_ORARENDIORA', 'C_ORATULAJDONOSID_BAK') IS NOT NULL)
BEGIN
    DISABLE TRIGGER tr_AsyncAuditORARENDIORA ON T_ORARENDIORA;
    EXECUTE('UPDATE T_ORARENDIORA SET C_ORATULAJDONOSID = C_ORATULAJDONOSID_BAK;');
    ENABLE TRIGGER tr_AsyncAuditORARENDIORA ON T_ORARENDIORA;
END
GO

ALTER TABLE [T_NEMKOTOTTMUNKAIDO]  DROP COLUMN IF EXISTS[C_TULAJDONOSID_BAK];
ALTER TABLE [T_ORARENDIORA] DROP COLUMN IF EXISTS[C_ORATULAJDONOSID_BAK];
GO

EXEC dev.uspCreateSchemaViews 'T_NEMKOTOTTMUNKAIDO,T_ORARENDIORA';
EXEC dev.sp_Global_GenerateAsyncAuditTriggerAll;
GO