RRinTetons
IS-IT--Management
SQL Server 2008 R2
I need to provide a desktop utility to allow a couple of users to run a specific SQL Agent job on demand.
I created an sp in MyDB that calls sp_runjob for the job I want to run.
USE [MyDB]
GO
CREATE PROCEDURE MyJobRunner
AS
EXEC [msdb].[dbo].[sp_start_job] N'MyJob'
GO
I created a .cmd using
SQLCMD -S MyServer -d MyDB -Q "EXEC dbo.MyJobRunner"
I added the users to MyDB with Public. I granted execute on the sp to the users required. I added the users to the SQLAgentUserRole in MSDB.
I can run the utility, they can't.
I tried WITH EXECUTE AS OWNER and it didn't work for me, nor for them.
Any ideas what's up? What log an error would appear in? Better ways to do this?
-
Richard Ray
DBA, Developer, Data Analyst
Jackson Hole Mountain Resort
I need to provide a desktop utility to allow a couple of users to run a specific SQL Agent job on demand.
I created an sp in MyDB that calls sp_runjob for the job I want to run.
USE [MyDB]
GO
CREATE PROCEDURE MyJobRunner
AS
EXEC [msdb].[dbo].[sp_start_job] N'MyJob'
GO
I created a .cmd using
SQLCMD -S MyServer -d MyDB -Q "EXEC dbo.MyJobRunner"
I added the users to MyDB with Public. I granted execute on the sp to the users required. I added the users to the SQLAgentUserRole in MSDB.
I can run the utility, they can't.
I tried WITH EXECUTE AS OWNER and it didn't work for me, nor for them.
Any ideas what's up? What log an error would appear in? Better ways to do this?
-
Richard Ray
DBA, Developer, Data Analyst
Jackson Hole Mountain Resort