dbTalk Databases Forums  

Executing Jobs via a SQL Statement

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Executing Jobs via a SQL Statement in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
JEH
 
Posts: n/a

Default Executing Jobs via a SQL Statement - 05-16-2005 , 08:36 AM






Does anyone know of a way to execute a job from a SQL Statement?

Reply With Quote
  #2  
Old   
Jacco Schalkwijk
 
Posts: n/a

Default Re: Executing Jobs via a SQL Statement - 05-16-2005 , 09:23 AM






EXEC sp_start_job '<job name>'

Note that you still need to be the owner of a job or a member of the
sysadmin server role to start jobs with sp_start_job, and that the
permissions are not transferable.

--
Jacco Schalkwijk
SQL Server MVP


"JEH" <JEH (AT) discussions (DOT) microsoft.com> wrote

Quote:
Does anyone know of a way to execute a job from a SQL Statement?



Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Executing Jobs via a SQL Statement - 05-17-2005 , 01:55 PM



In addition to Jacco's most excellent advice you need to note the
context of the person running the job based on who you are

From BOL.

When sp_start_job is invoked by a user who is a member of the sysadmin
fixed server role, sp_start_job will be executed under the security
context in which the SQL Server service is running. When the user is not
a member of the sysadmin fixed server role, sp_start_job will
impersonate the SQL Server Agent proxy account, which is specified using
xp_sqlagent_proxy_account. If the proxy account is not available,
sp_start_job will fail. This is only true for MicrosoftR Windows NTR 4.0
and Windows 2000. On Windows 9.x, there is no impersonation and
sp_start_job is always executed under the security context of the
Windows 9.x user who started SQL Server.



"Jacco Schalkwijk" <jacco.please.reply (AT) to (DOT) newsgroups.mvps.org.invalid>
wrote in message news:jacco.please.reply (AT) to (DOT) newsgroups.mvps.org.invalid:

Quote:
EXEC sp_start_job '<job name>'

Note that you still need to be the owner of a job or a member of the
sysadmin server role to start jobs with sp_start_job, and that the
permissions are not transferable.

--
Jacco Schalkwijk
SQL Server MVP


"JEH" <JEH (AT) discussions (DOT) microsoft.com> wrote in message
news:660F3EA9-7D83-42B9-8AB9-73C91BE54C27 (AT) microsoft (DOT) com...
Does anyone know of a way to execute a job from a SQL Statement?


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.