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? |