chuck writes "I have a problem. I want to create a trigger on msdb.dbo.sysjobs that inserts the name of all inserted dts packages into a table named "tracking_change_owner". This table only has one field "name" to hold this value. Then I have a trigger on that table that I want to invoke the stored procedure "sp_update_job". I have learned from research that a dynamic execute is considered a different "scope" and that any local variables you create cannot be accessed from inside the EXEC string. I have tried every imaginable way to invoke sp_update job from a trigger. Can you think of anything I may want to try?/*****************************************************************************************************/CREATE TABLE dbo.tracking_change_owner( name sysname NOT NULL)GO/*****************************************************************************************************/CREATE TRIGGER ti_sysjobs ON sysjobs FOR INSERTAS BEGIN INSERT into tracking_change_owner (name) select name FROM inserted ENDGO/*****************************************************************************************************/CREATE trigger ti_tracking_change_ownerASDECLARE @vJob_name sysname,@vSQL varchar(1000)SELECT @vJob_name = name from tracking_change_owner SELECT @vSQL = 'sp_update_job @job_name = "' + convert(varchar, @vJob_name) + '", @owner_login_name = "sa"' exec (@vSQL)GO/*****************************************************************************************************/
"