Showing posts with label jobs. Show all posts
Showing posts with label jobs. Show all posts

Friday, March 30, 2012

Running bat files in SSIS

Folks -

Did you have any success when running bat files (Execute Process Task) from SSIS through SQL Server Agent jobs? My package will succeed when I run it from my machine, when I ask the DBA to run it manually from the Server but not when we run from a job.

The job will hang and the bat file does not seem to be executed. The executable property does evaluate to the right path and the package owner does have write/execute permissions in the folder where the bat file is located.

Everything I could find close to that is under <http://support.microsoft.com/kb/918760>. Would you shed any light on this? When I run the same bat file from a DTS through SQL Server Agent job, it will work with no issues. Any help would be very much appreciated.

Thanks.

Does the batch file have any prompts that require user input?|||

What is SQL Agent Service account running with?

Is it the same account that you are your DBA use - when running the package manually?

Because when you run the job - it runs with the credential of SQL Agent account.

|||Phil, thxs 4 your reply. No prompts that will require user input. The bat file will do a ftp. Thanks again.|||

How do I check what is SQL Agent Service account running my job? I know when I run the pkg manually it will run under my ID.

I do own the SQL Agent job in the Development environment so the DBA told me that my ID should be trying to execute the bat file (as I said before my ID has the permissions so there is something very strange happening). She said when I move to MO it will be owned by SA.

I can't go to MO if it is not working in DEV Wink

Thanks for your reply.

|||If you are using the SSIS job step to run the package, it runs under the service account that the Agent is set up to use, not the job owner's account. Try setting up a proxy account - check books online for details.|||

Hi,

It's simple. Use an Execute Process Task.

Double Click the Task, Under Process Tab, set the values for the following properties:

1) Executable = cmd.exe

2) Arguments = /c C:\BatchFolder\MyFile.bat.

Make Sure when you run the job, The Service account that runs your job should have access to this batch file.

Thanks

Subhash Subramanyam

|||

Jwelch -

There is a proxy account set by the DBA already... When we add a step to a job, for type we do "Operating system (CmdExec)" and for run as we do "SQLAgentJobProxy".

So... Do you believe this proxy account is the one with no access to run the bat file?

Thanks.

|||

That would be my guess.

Also, is the bat file located on a local drive, network share with UNC path, or a mapped drive?

|||Network share with UNC path.|||Might try copying it locally and see if that makes a difference.|||

I don't have Integration Services installed locally. I will check with the DBA on the permissions mentioned here and I will let you guys know.

Thanks.

|||

Folks,

The feedback I had from my DBA was that the SQLAgentProxyAccount does have access to execute the bat file in question... This is proved when I run a dts through the same job and the same bat file is fired successfully. She also agreed that the Executable Property in the Execute Process Task step was evaluating correctly.

So, our work-around was to remove the bat file execution from the SSIS pkg and add it to the second step of the job. Dirty and scary if you think that the ftp might not be the last step of a whole process. In my case, thanks to God it is... But since we have lack of time right now, this is the solution we put in place.

I would say the issue is still not clarified but I will mark this as closed and if somebody in the future runs into the same problem a new thread could be opened.

Thanks to all.

Running bat files in SSIS

Folks -

Did you have any success when running bat files (Execute Process Task) from SSIS through SQL Server Agent jobs? My package will succeed when I run it from my machine, when I ask the DBA to run it manually from the Server but not when we run from a job.

The job will hang and the bat file does not seem to be executed. The executable property does evaluate to the right path and the package owner does have write/execute permissions in the folder where the bat file is located.

Everything I could find close to that is under <http://support.microsoft.com/kb/918760>. Would you shed any light on this? When I run the same bat file from a DTS through SQL Server Agent job, it will work with no issues. Any help would be very much appreciated.

Thanks.

Does the batch file have any prompts that require user input?|||

What is SQL Agent Service account running with?

Is it the same account that you are your DBA use - when running the package manually?

Because when you run the job - it runs with the credential of SQL Agent account.

|||Phil, thxs 4 your reply. No prompts that will require user input. The bat file will do a ftp. Thanks again.|||

How do I check what is SQL Agent Service account running my job? I know when I run the pkg manually it will run under my ID.

I do own the SQL Agent job in the Development environment so the DBA told me that my ID should be trying to execute the bat file (as I said before my ID has the permissions so there is something very strange happening). She said when I move to MO it will be owned by SA.

I can't go to MO if it is not working in DEV Wink

Thanks for your reply.

|||If you are using the SSIS job step to run the package, it runs under the service account that the Agent is set up to use, not the job owner's account. Try setting up a proxy account - check books online for details.|||

Hi,

It's simple. Use an Execute Process Task.

Double Click the Task, Under Process Tab, set the values for the following properties:

1) Executable = cmd.exe

2) Arguments = /c C:\BatchFolder\MyFile.bat.

Make Sure when you run the job, The Service account that runs your job should have access to this batch file.

Thanks

Subhash Subramanyam

|||

Jwelch -

There is a proxy account set by the DBA already... When we add a step to a job, for type we do "Operating system (CmdExec)" and for run as we do "SQLAgentJobProxy".

So... Do you believe this proxy account is the one with no access to run the bat file?

Thanks.

|||

That would be my guess.

Also, is the bat file located on a local drive, network share with UNC path, or a mapped drive?

|||Network share with UNC path.|||Might try copying it locally and see if that makes a difference.|||

I don't have Integration Services installed locally. I will check with the DBA on the permissions mentioned here and I will let you guys know.

Thanks.

|||

Folks,

The feedback I had from my DBA was that the SQLAgentProxyAccount does have access to execute the bat file in question... This is proved when I run a dts through the same job and the same bat file is fired successfully. She also agreed that the Executable Property in the Execute Process Task step was evaluating correctly.

So, our work-around was to remove the bat file execution from the SSIS pkg and add it to the second step of the job. Dirty and scary if you think that the ftp might not be the last step of a whole process. In my case, thanks to God it is... But since we have lack of time right now, this is the solution we put in place.

I would say the issue is still not clarified but I will mark this as closed and if somebody in the future runs into the same problem a new thread could be opened.

Thanks to all.

Running Backup Jobs

Hi everyone
I have a SQL Server 2005. On this server is a database that only a handfull
of users may access - This excludes the normal IT people such as Domain
Admins etc. Only problem is that if I remove BuiltIn\Administrators from the
sysadmin server role I am no longer able to do backups of the database. If I
leave the BuiltIn\Administrator in the SysAdmin role they can access the
database.
Any help would be appriciated.
Thanks.
Regards
JonasJonas
By default all members of Administrators group have login SQL Server .
What is an account SQL Server Agent running under? Is it Local Account?
Create a user domain account/group on the box SQL Server running on. Change
Sql Server Agent's/MSSqlService account to this new one but make sure that
this account has an appropriate permissions to access the network
"Jonas Larsen" <JonasLarsen@.discussions.microsoft.com> wrote in message
news:C06D17CC-95A2-48A3-BFD7-6288CA2918BE@.microsoft.com...
> Hi everyone
> I have a SQL Server 2005. On this server is a database that only a
> handfull
> of users may access - This excludes the normal IT people such as Domain
> Admins etc. Only problem is that if I remove BuiltIn\Administrators from
> the
> sysadmin server role I am no longer able to do backups of the database. If
> I
> leave the BuiltIn\Administrator in the SysAdmin role they can access the
> database.
> Any help would be appriciated.
> Thanks.
> Regards
> Jonas|||Thanks for that. The Agent was running Local System, changed that as
suggested and then removed builtin admin from the sysadmin role. Everything
works.
"Uri Dimant" wrote:

> Jonas
> By default all members of Administrators group have login SQL Server .
> What is an account SQL Server Agent running under? Is it Local Account?
> Create a user domain account/group on the box SQL Server running on. Chan
ge
> Sql Server Agent's/MSSqlService account to this new one but make sure that
> this account has an appropriate permissions to access the network
>
>
> "Jonas Larsen" <JonasLarsen@.discussions.microsoft.com> wrote in message
> news:C06D17CC-95A2-48A3-BFD7-6288CA2918BE@.microsoft.com...
>
>sql

Running agent jobs from command line

Hi,
How can i run a SQL Server Agent Job from the command line on the same box? I am using SQL Server 2000.
ThanksCheck out the SQL Books Online for Command Line execution of SQL Agent

The dtsrun utility executes a package created using Data Transformation Services (DTS). The DTS package can be stored in the Microsoft SQL Server msdb database, a COM-structured storage file, or SQL Server Meta Data Services.

Syntax
dtsrun
[/?] |
[
[
/[~]S server_name[\instance_name]
{ {/[~]U user_name [/[~]P password]} | /E }
]
{
{/[~]N package_name }
| {/[~]G package_guid_string}
| {/[~]V package_version_guid_string}
}
[/[~]M package_password]
[/[~]F filename]
[/[~]R repository_database_name]
[/A global_variable_name:typeid=value]
[/L log_file_name]
[/W NT_event_log_completion_status]
[/Z] [/!X] [/!D] [/!Y] [/!C]
]

dtsrun /Sserver_name /Uuser_nName /Ppassword /Npackage_name /Mpackage_password|||So i have to create a DTS package to run my job and then use dtsrun to run that package?|||Sorry I sent you the wrong script. I'll be back with the correct one shortly. Mark|||You could create a stored procedure to run the job. Example:
(You may be able to pass the name through as a parameter ??)

CREATE PROCEDURE sp_RunJob
AS

BEGIN

EXEC msdb..sp_start_job @.job_name = 'The job name'

END

You can also use the job id etc... do a search in the Books Online for sp_start_job and you'll get the syntax.

Then from the command line, create a .bat file and put the following isql command synax into the .bat file:

isql /U username -n -E /d "database name" -Q "stored procedure name" /S servername -oC:\returncode.txt

This will actually produce some output into the returncode.txt file, which might be useful. I'm not sure whether you'll have to return a value back out of the stored procedure or not. I've not tried. My sample above it a cut down version. But anyhow there should be enough above to give you the idea in terms of syntax etc.

You would then just execute the .bat file on your server/pc etc, perhaps via a scheduler etc...

Anyhow a search on SQL Books Online will give you all the details. Search for isql , isqlw etc..|||Cheers Mark.

Wednesday, March 28, 2012

running a stored procedure from one server to access jobs on another

I have two servers linked. I can run an SP on one server to access jobs on
the other server. I cannot make this work the other way around?
this works from server1
server2.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
Logs',@.enabled =1
This fails with the error msg Could not connect to server 'server1' because
'sa' is not defined as a remote login at the server.
server1.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
Logs',@.enabled =1Did you map logins from server 2 to server 1? Also, it seems you login as sa on server 2, I never
recommend anyone logging in as sa.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Andy Phillips" <andy.phillips@.callatg.com> wrote in message
news:%23eH52BB2EHA.3820@.TK2MSFTNGP11.phx.gbl...
> I have two servers linked. I can run an SP on one server to access jobs on
> the other server. I cannot make this work the other way around?
> this works from server1
> server2.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> Logs',@.enabled =1
> This fails with the error msg Could not connect to server 'server1' because
> 'sa' is not defined as a remote login at the server.
> server1.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> Logs',@.enabled =1
>|||Do you have a linked server set up on both servers? A linked server only
works in one direction. You need a linked server set up on both servers to be
able to go both ways.
"Andy Phillips" wrote:
> I have two servers linked. I can run an SP on one server to access jobs on
> the other server. I cannot make this work the other way around?
> this works from server1
> server2.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> Logs',@.enabled =1
> This fails with the error msg Could not connect to server 'server1' because
> 'sa' is not defined as a remote login at the server.
> server1.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> Logs',@.enabled =1
>
>|||All I did was link the servers.Please explain what I should do.
Thanks
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:Obs8SCE2EHA.2568@.TK2MSFTNGP11.phx.gbl...
> Did you map logins from server 2 to server 1? Also, it seems you login as
sa on server 2, I never
> recommend anyone logging in as sa.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Andy Phillips" <andy.phillips@.callatg.com> wrote in message
> news:%23eH52BB2EHA.3820@.TK2MSFTNGP11.phx.gbl...
> > I have two servers linked. I can run an SP on one server to access jobs
on
> > the other server. I cannot make this work the other way around?
> >
> > this works from server1
> > server2.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> > Logs',@.enabled =1
> >
> > This fails with the error msg Could not connect to server 'server1'
because
> > 'sa' is not defined as a remote login at the server.
> >
> > server1.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> > Logs',@.enabled =1
> >
> >
>|||If you use EM, right.click the linked server, Properties, and the security tab. Map the login there.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Andy Phillips" <andy.phillips@.callatg.com> wrote in message
news:%23ogJfYJ2EHA.2624@.TK2MSFTNGP11.phx.gbl...
> All I did was link the servers.Please explain what I should do.
> Thanks
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:Obs8SCE2EHA.2568@.TK2MSFTNGP11.phx.gbl...
> > Did you map logins from server 2 to server 1? Also, it seems you login as
> sa on server 2, I never
> > recommend anyone logging in as sa.
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/default.asp
> > http://www.solidqualitylearning.com/
> >
> >
> > "Andy Phillips" <andy.phillips@.callatg.com> wrote in message
> > news:%23eH52BB2EHA.3820@.TK2MSFTNGP11.phx.gbl...
> > > I have two servers linked. I can run an SP on one server to access jobs
> on
> > > the other server. I cannot make this work the other way around?
> > >
> > > this works from server1
> > > server2.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> > > Logs',@.enabled =1
> > >
> > > This fails with the error msg Could not connect to server 'server1'
> because
> > > 'sa' is not defined as a remote login at the server.
> > >
> > > server1.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> > > Logs',@.enabled =1
> > >
> > >
> >
> >
>|||I cannot link the other server. It sys it already exists although it shows
no items in the list?
"Robert Davis" <RobertDavis@.discussions.microsoft.com> wrote in message
news:59EB1C48-4211-4D42-BC9E-79D354C5C3B6@.microsoft.com...
> Do you have a linked server set up on both servers? A linked server only
> works in one direction. You need a linked server set up on both servers to
be
> able to go both ways.
> "Andy Phillips" wrote:
> > I have two servers linked. I can run an SP on one server to access jobs
on
> > the other server. I cannot make this work the other way around?
> >
> > this works from server1
> > server2.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> > Logs',@.enabled =1
> >
> > This fails with the error msg Could not connect to server 'server1'
because
> > 'sa' is not defined as a remote login at the server.
> >
> > server1.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> > Logs',@.enabled =1
> >
> >
> >|||It'sa fixed. Thanks Robert. I had to remove remote servers and linked
servers and then relink them. I have links each way now and all is working
top. Thanks
"Andy Phillips" <andy.phillips@.callatg.com> wrote in message
news:uFGWTEC3EHA.3932@.TK2MSFTNGP12.phx.gbl...
> I cannot link the other server. It sys it already exists although it shows
> no items in the list?
>
> "Robert Davis" <RobertDavis@.discussions.microsoft.com> wrote in message
> news:59EB1C48-4211-4D42-BC9E-79D354C5C3B6@.microsoft.com...
> > Do you have a linked server set up on both servers? A linked server only
> > works in one direction. You need a linked server set up on both servers
to
> be
> > able to go both ways.
> >
> > "Andy Phillips" wrote:
> >
> > > I have two servers linked. I can run an SP on one server to access
jobs
> on
> > > the other server. I cannot make this work the other way around?
> > >
> > > this works from server1
> > > server2.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB
Trans
> > > Logs',@.enabled =1
> > >
> > > This fails with the error msg Could not connect to server 'server1'
> because
> > > 'sa' is not defined as a remote login at the server.
> > >
> > > server1.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB
Trans
> > > Logs',@.enabled =1
> > >
> > >
> > >
>

running a stored procedure from one server to access jobs on another

I have two servers linked. I can run an SP on one server to access jobs on
the other server. I cannot make this work the other way around?
this works from server1
server2.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
Logs',@.enabled =1
This fails with the error msg Could not connect to server 'server1' because
'sa' is not defined as a remote login at the server.
server1.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
Logs',@.enabled =1
Did you map logins from server 2 to server 1? Also, it seems you login as sa on server 2, I never
recommend anyone logging in as sa.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Andy Phillips" <andy.phillips@.callatg.com> wrote in message
news:%23eH52BB2EHA.3820@.TK2MSFTNGP11.phx.gbl...
> I have two servers linked. I can run an SP on one server to access jobs on
> the other server. I cannot make this work the other way around?
> this works from server1
> server2.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> Logs',@.enabled =1
> This fails with the error msg Could not connect to server 'server1' because
> 'sa' is not defined as a remote login at the server.
> server1.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> Logs',@.enabled =1
>
|||All I did was link the servers.Please explain what I should do.
Thanks
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:Obs8SCE2EHA.2568@.TK2MSFTNGP11.phx.gbl...
> Did you map logins from server 2 to server 1? Also, it seems you login as
sa on server 2, I never[vbcol=seagreen]
> recommend anyone logging in as sa.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Andy Phillips" <andy.phillips@.callatg.com> wrote in message
> news:%23eH52BB2EHA.3820@.TK2MSFTNGP11.phx.gbl...
on[vbcol=seagreen]
because
>
|||If you use EM, right.click the linked server, Properties, and the security tab. Map the login there.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Andy Phillips" <andy.phillips@.callatg.com> wrote in message
news:%23ogJfYJ2EHA.2624@.TK2MSFTNGP11.phx.gbl...
> All I did was link the servers.Please explain what I should do.
> Thanks
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:Obs8SCE2EHA.2568@.TK2MSFTNGP11.phx.gbl...
> sa on server 2, I never
> on
> because
>

running a stored procedure from one server to access jobs on another

I have two servers linked. I can run an SP on one server to access jobs on
the other server. I cannot make this work the other way around?
this works from server1
server2.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
Logs',@.enabled =1
This fails with the error msg Could not connect to server 'server1' because
'sa' is not defined as a remote login at the server.
server1.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
Logs',@.enabled =1Did you map logins from server 2 to server 1? Also, it seems you login as sa
on server 2, I never
recommend anyone logging in as sa.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Andy Phillips" <andy.phillips@.callatg.com> wrote in message
news:%23eH52BB2EHA.3820@.TK2MSFTNGP11.phx.gbl...
> I have two servers linked. I can run an SP on one server to access jobs o
n
> the other server. I cannot make this work the other way around?
> this works from server1
> server2.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> Logs',@.enabled =1
> This fails with the error msg Could not connect to server 'server1' becaus
e
> 'sa' is not defined as a remote login at the server.
> server1.msdb..sp_update_job @.job_name = 'Copy And Restore FFICDB Trans
> Logs',@.enabled =1
>|||All I did was link the servers.Please explain what I should do.
Thanks
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:Obs8SCE2EHA.2568@.TK2MSFTNGP11.phx.gbl...
> Did you map logins from server 2 to server 1? Also, it seems you login as
sa on server 2, I never
> recommend anyone logging in as sa.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Andy Phillips" <andy.phillips@.callatg.com> wrote in message
> news:%23eH52BB2EHA.3820@.TK2MSFTNGP11.phx.gbl...
on[vbcol=seagreen]
because[vbcol=seagreen]
>|||If you use EM, right.click the linked server, Properties, and the security t
ab. Map the login there.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Andy Phillips" <andy.phillips@.callatg.com> wrote in message
news:%23ogJfYJ2EHA.2624@.TK2MSFTNGP11.phx.gbl...
> All I did was link the servers.Please explain what I should do.
> Thanks
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n
> message news:Obs8SCE2EHA.2568@.TK2MSFTNGP11.phx.gbl...
> sa on server 2, I never
> on
> because
>

Friday, March 23, 2012

Running 2005 SSIS Jobs on 2000

I would like to create an SSIS package in 2005 and run it in 2000. Is there anyway to do this? Or does SQL Server 2000 have a precursor to SSIS? I am trying to create a job to automatically catch and kill orphaned processes.
-Kyle
DTS is the product you will need to use in SQL Server 2000.

Runnable jobs

Hi,
Jobs panel of SQL server Agent has columns which show if job is Enabled,
Runnable, Scheduled.
How to disable Runnable value?
Job interface doesn't support such option, nor table msdb.dbo.sysjobs has
such column.
I use SS2000, SP4, Win 2000 Advance, SP4.
Thanks in advance
Nikola Milicif you delete all child job steps from the job, the "runnable" will show
"NO". oh, you cannot do it from within enterprise manager.
here is a quick demo. run the query below to create an empty job then check
EM for the runnable status.
exec msdb.dbo.sp_add_job @.job_name = N'test'
-oj
"Nikola Milic" <hotmnikola@.hotmail.com> wrote in message
news:uiHdBpClGHA.3720@.TK2MSFTNGP03.phx.gbl...
> Hi,
> Jobs panel of SQL server Agent has columns which show if job is Enabled,
> Runnable, Scheduled.
> How to disable Runnable value?
> Job interface doesn't support such option, nor table msdb.dbo.sysjobs has
> such column.
>
> I use SS2000, SP4, Win 2000 Advance, SP4.
> Thanks in advance
> Nikola Milic
>|||Nikola Milic wrote:
> Hi,
> Jobs panel of SQL server Agent has columns which show if job is Enabled,
> Runnable, Scheduled.
> How to disable Runnable value?
> Job interface doesn't support such option, nor table msdb.dbo.sysjobs has
> such column.
>
> I use SS2000, SP4, Win 2000 Advance, SP4.
> Thanks in advance
> Nikola Milic
>
If you right click on the job on select properties you have an "Enabled"
check box on the first pane. By unclicking this you disable the job.
Regards
Steen Schlter Persson
Databaseadministrator / Systemadministrator|||if you delete all child job steps from the job, the "runnable" will show
"NO". oh, you cannot do it from within enterprise manager.
here is a quick demo. run the query below to create an empty job then check
EM for the runnable status.
exec msdb.dbo.sp_add_job @.job_name = N'test'
-oj
"Nikola Milic" <hotmnikola@.hotmail.com> wrote in message
news:uiHdBpClGHA.3720@.TK2MSFTNGP03.phx.gbl...
> Hi,
> Jobs panel of SQL server Agent has columns which show if job is Enabled,
> Runnable, Scheduled.
> How to disable Runnable value?
> Job interface doesn't support such option, nor table msdb.dbo.sysjobs has
> such column.
>
> I use SS2000, SP4, Win 2000 Advance, SP4.
> Thanks in advance
> Nikola Milic
>|||Nikola Milic wrote:
> Hi,
> Jobs panel of SQL server Agent has columns which show if job is Enabled,
> Runnable, Scheduled.
> How to disable Runnable value?
> Job interface doesn't support such option, nor table msdb.dbo.sysjobs has
> such column.
>
> I use SS2000, SP4, Win 2000 Advance, SP4.
> Thanks in advance
> Nikola Milic
>
If you right click on the job on select properties you have an "Enabled"
check box on the first pane. By unclicking this you disable the job.
Regards
Steen Schlter Persson
Databaseadministrator / Systemadministrator

Runnable jobs

Hi,
Jobs panel of SQL server Agent has columns which show if job is Enabled,
Runnable, Scheduled.
How to disable Runnable value?
Job interface doesn't support such option, nor table msdb.dbo.sysjobs has
such column.
I use SS2000, SP4, Win 2000 Advance, SP4.
Thanks in advance
Nikola Milicif you delete all child job steps from the job, the "runnable" will show
"NO". oh, you cannot do it from within enterprise manager.
here is a quick demo. run the query below to create an empty job then check
EM for the runnable status.
exec msdb.dbo.sp_add_job @.job_name = N'test'
-oj
"Nikola Milic" <hotmnikola@.hotmail.com> wrote in message
news:uiHdBpClGHA.3720@.TK2MSFTNGP03.phx.gbl...
> Hi,
> Jobs panel of SQL server Agent has columns which show if job is Enabled,
> Runnable, Scheduled.
> How to disable Runnable value?
> Job interface doesn't support such option, nor table msdb.dbo.sysjobs has
> such column.
>
> I use SS2000, SP4, Win 2000 Advance, SP4.
> Thanks in advance
> Nikola Milic
>|||Nikola Milic wrote:
> Hi,
> Jobs panel of SQL server Agent has columns which show if job is Enabled,
> Runnable, Scheduled.
> How to disable Runnable value?
> Job interface doesn't support such option, nor table msdb.dbo.sysjobs has
> such column.
>
> I use SS2000, SP4, Win 2000 Advance, SP4.
> Thanks in advance
> Nikola Milic
>
If you right click on the job on select properties you have an "Enabled"
check box on the first pane. By unclicking this you disable the job.
Regards
Steen Schlüter Persson
Databaseadministrator / Systemadministrator

runaway jobs

Hi,
Some of my developers have scheduled jobs which run for hours...how can i get an alert on job that have been running for more than 30 minutes.Use SP_HELP_JOB repeatedly to get the execution status.

Also make sure to identify why those jobs are taking too long to return the status/completion.|||msdb..sysjobhistory tables has fields that could help you:

run_status (int) - Status of the job execution:
0 = Failed
1 = Succeeded
2 = Retry
3 = Canceled
4 = In progress

run_date (int) - Date the job or step started execution. For an In Progress history, this is the date/time the history was written.|||MS discourages querying directly SYSTEM tables, I believe SP_HELP_JOB does give same information.|||knock the developers heads together ? maybe then they will be a bit more thoughtfull about the performace of their jobs ...|||NetIQ has a piece of software called DiagnosticsManager for SQL that will monitor problem queries.|||Hi I am writing a script to check quickly jobs which failed or running endlessly.

I am checking the sysjobhistory run_status field

run_status (int) - Status of the job execution:
0 = Failed
1 = Succeeded
2 = Retry
3 = Canceled
4 = In progress

After lots of tests, I never saw status 4 when a job is running so I cannot perform my task correctly...|||Originally posted by Satya
MS discourages querying directly SYSTEM tables, I believe SP_HELP_JOB does give same information.

Wierd !!!

I did not get this one ...Running this much code instead of one single query is recommended by MS

CREATE PROCEDURE sp_help_job
-- Individual job parameters
@.job_id UNIQUEIDENTIFIER = NULL, -- If provided should NOT also provide job_name
@.job_name sysname = NULL, -- If provided should NOT also provide job_id
@.job_aspect VARCHAR(9) = NULL, -- JOB, STEPS, SCEDULES, TARGETS or ALL
-- Job set parameters
@.job_type VARCHAR(12) = NULL, -- LOCAL or MULTI-SERVER
@.owner_login_name sysname = NULL,
@.subsystem NVARCHAR(40) = NULL,
@.category_name sysname = NULL,
@.enabled TINYINT = NULL,
@.execution_status INT = NULL, -- 1 = Executing, 2 = Waiting For Thread, 3 = Between Retries, 4 = Idle, 5 = Suspended, 6 = [obsolete], 7 = PerformingCompletionActions
@.date_comparator CHAR(1) = NULL, -- >, < or =
@.date_created DATETIME = NULL,
@.date_last_modified DATETIME = NULL,
@.description NVARCHAR(512) = NULL -- We do a LIKE on this so it can include wildcards
AS
BEGIN
DECLARE @.retval INT
DECLARE @.category_id INT
DECLARE @.job_id_as_char VARCHAR(36)
DECLARE @.res_valid_range NVARCHAR(200)

SET NOCOUNT ON

-- Remove any leading/trailing spaces from parameters (except @.owner_login_name)
SELECT @.job_name = LTRIM(RTRIM(@.job_name))
SELECT @.job_aspect = LTRIM(RTRIM(@.job_aspect))
SELECT @.job_type = LTRIM(RTRIM(@.job_type))
SELECT @.subsystem = LTRIM(RTRIM(@.subsystem))
SELECT @.category_name = LTRIM(RTRIM(@.category_name))
SELECT @.description = LTRIM(RTRIM(@.description))

-- Turn [nullable] empty string parameters into NULLs
IF (@.job_name = N'') SELECT @.job_name = NULL
IF (@.job_aspect = '') SELECT @.job_aspect = NULL
IF (@.job_type = '') SELECT @.job_type = NULL
IF (@.owner_login_name = N'') SELECT @.owner_login_name = NULL
IF (@.subsystem = N'') SELECT @.subsystem = NULL
IF (@.category_name = N'') SELECT @.category_name = NULL
IF (@.description = N'') SELECT @.description = NULL

IF ((@.job_id IS NOT NULL) OR (@.job_name IS NOT NULL))
BEGIN
EXECUTE @.retval = sp_verify_job_identifiers '@.job_name',
'@.job_id',
@.job_name OUTPUT,
@.job_id OUTPUT
IF (@.retval <> 0)
RETURN(1) -- Failure
END

SELECT @.job_id_as_char = CONVERT(VARCHAR(36), @.job_id)

-- If the user provided a job name or id but no aspect, default to ALL
IF ((@.job_name IS NOT NULL) OR (@.job_id IS NOT NULL)) AND (@.job_aspect IS NULL)
SELECT @.job_aspect = 'ALL'

-- The caller must supply EITHER job name (or job id) and aspect OR one-or-more of the set
-- parameters OR no parameters at all
IF (((@.job_name IS NOT NULL) OR (@.job_id IS NOT NULL))
AND ((@.job_aspect IS NULL) OR
(@.job_type IS NOT NULL) OR
(@.owner_login_name IS NOT NULL) OR
(@.subsystem IS NOT NULL) OR
(@.category_name IS NOT NULL) OR
(@.enabled IS NOT NULL) OR
(@.date_comparator IS NOT NULL) OR
(@.date_created IS NOT NULL) OR
(@.date_last_modified IS NOT NULL)))
OR
((@.job_name IS NULL) AND (@.job_id IS NULL) AND (@.job_aspect IS NOT NULL))
BEGIN
RAISERROR(14280, -1, -1)
RETURN(1) -- Failure
END

IF (@.job_id IS NOT NULL)
BEGIN
-- Individual job...

-- Check job aspect
SELECT @.job_aspect = UPPER(@.job_aspect)
IF (@.job_aspect NOT IN ('JOB', 'STEPS', 'SCHEDULES', 'TARGETS', 'ALL'))
BEGIN
RAISERROR(14266, -1, -1, '@.job_aspect', 'JOB, STEPS, SCHEDULES, TARGETS, ALL')
RETURN(1) -- Failure
END

-- Generate results set...

IF (@.job_aspect IN ('JOB', 'ALL'))
BEGIN
IF (@.job_aspect = 'ALL')
BEGIN
RAISERROR(14213, 0, 1)
PRINT REPLICATE('=', DATALENGTH(FORMATMESSAGE(14213)) / 2)
END
EXECUTE sp_get_composite_job_info @.job_id,
@.job_type,
@.owner_login_name,
@.subsystem,
@.category_id,
@.enabled,
@.execution_status,
@.date_comparator,
@.date_created,
@.date_last_modified,
@.description
END

IF (@.job_aspect IN ('STEPS', 'ALL'))
BEGIN
IF (@.job_aspect = 'ALL')
BEGIN
PRINT ''
RAISERROR(14214, 0, 1)
PRINT REPLICATE('=', DATALENGTH(FORMATMESSAGE(14214)) / 2)
END
EXECUTE ('EXECUTE sp_help_jobstep @.job_id = ''' + @.job_id_as_char + ''', @.suffix = 1')
END

IF (@.job_aspect IN ('SCHEDULES', 'ALL'))
BEGIN
IF (@.job_aspect = 'ALL')
BEGIN
PRINT ''
RAISERROR(14215, 0, 1)
PRINT REPLICATE('=', DATALENGTH(FORMATMESSAGE(14215)) / 2)
END
EXECUTE ('EXECUTE sp_help_jobschedule @.job_id = ''' + @.job_id_as_char + '''')
END

IF (@.job_aspect IN ('TARGETS', 'ALL'))
BEGIN
IF (@.job_aspect = 'ALL')
BEGIN
PRINT ''
RAISERROR(14216, 0, 1)
PRINT REPLICATE('=', DATALENGTH(FORMATMESSAGE(14216)) / 2)
END
EXECUTE ('EXECUTE sp_help_jobserver @.job_id = ''' + @.job_id_as_char + ''', @.show_last_run_details = 1')
END
END
ELSE
BEGIN
-- Set of jobs...

-- Check job type
IF (@.job_type IS NOT NULL)
BEGIN
SELECT @.job_type = UPPER(@.job_type)
IF (@.job_type NOT IN ('LOCAL', 'MULTI-SERVER'))
BEGIN
RAISERROR(14266, -1, -1, '@.job_type', 'LOCAL, MULTI-SERVER')
RETURN(1) -- Failure
END
END

-- Check owner
IF (@.owner_login_name IS NOT NULL)
BEGIN
IF (SUSER_SID(@.owner_login_name) IS NULL)
BEGIN
RAISERROR(14262, -1, -1, '@.owner_login_name', @.owner_login_name)
RETURN(1) -- Failure
END
END

-- Check subsystem
IF (@.subsystem IS NOT NULL)
BEGIN
EXECUTE @.retval = sp_verify_subsystem @.subsystem
IF (@.retval <> 0)
RETURN(1) -- Failure
END

-- Check job category
IF (@.category_name IS NOT NULL)
BEGIN
SELECT @.category_id = category_id
FROM msdb.dbo.syscategories
WHERE (category_class = 1) -- Job
AND (name = @.category_name)
IF (@.category_id IS NULL)
BEGIN
RAISERROR(14262, -1, -1, '@.category_name', @.category_name)
RETURN(1) -- Failure
END
END

-- Check enabled state
IF (@.enabled IS NOT NULL) AND (@.enabled NOT IN (0, 1))
BEGIN
RAISERROR(14266, -1, -1, '@.enabled', '0, 1')
RETURN(1) -- Failure
END

-- Check current execution status
IF (@.execution_status IS NOT NULL)
BEGIN
IF (@.execution_status NOT IN (0, 1, 2, 3, 4, 5, 7))
BEGIN
SELECT @.res_valid_range = FORMATMESSAGE(14204)
RAISERROR(14266, -1, -1, '@.execution_status', @.res_valid_range)
RETURN(1) -- Failure
END
END

-- If a date comparator is supplied, we must have either a date-created or date-last-modified
IF ((@.date_comparator IS NOT NULL) AND (@.date_created IS NOT NULL) AND (@.date_last_modified IS NOT NULL)) OR
((@.date_comparator IS NULL) AND ((@.date_created IS NOT NULL) OR (@.date_last_modified IS NOT NULL)))
BEGIN
RAISERROR(14282, -1, -1)
RETURN(1) -- Failure
END

-- Check dates / comparator
IF (@.date_comparator IS NOT NULL) AND (@.date_comparator NOT IN ('=', '<', '>'))
BEGIN
RAISERROR(14266, -1, -1, '@.date_comparator', '=, >, <')
RETURN(1) -- Failure
END
IF (@.date_created IS NOT NULL) AND
((@.date_created < '1 Jan 1990 12:00:00am') OR (@.date_created > '31 Dec 9999 11:59:59pm'))
BEGIN
RAISERROR(14266, -1, -1, '@.date_created', '1/1/1990 12:00am .. 12/31/9999 11:59pm')
RETURN(1) -- Failure
END
IF (@.date_last_modified IS NOT NULL) AND
((@.date_last_modified < '1 Jan 1990 12:00am') OR (@.date_last_modified > 'Dec 31 9999 11:59:59pm'))
BEGIN
RAISERROR(14266, -1, -1, '@.date_last_modified', '1/1/1990 12:00am .. 12/31/9999 11:59pm')
RETURN(1) -- Failure
END

-- Generate results set...
EXECUTE sp_get_composite_job_info @.job_id,
@.job_type,
@.owner_login_name,
@.subsystem,
@.category_id,
@.enabled,
@.execution_status,
@.date_comparator,
@.date_created,
@.date_last_modified,
@.description
END

RETURN(0) -- Success
END|||Hi !

In effect this store proc returns the fields I need but I wonder how can I perform a select from the result of this store proc ?

Shourl I redirect the result of the stored proc to a temporary table and if yes what is the redirection instruction ?

Could you help please ?|||INSERT INTO myTable99 EXEC sp_whatever..

my favorite line of MS code is in sp_help

-- IF NOT IN SYSOBJECTS, TRY SYSTYPES --
if @.objid is null
begin
-- UNDONE: SHOULD CHECK FOR AND DISALLOW MULTI-PART NAME
select @.objid = xusertype from systypes where name = @.objname

-- IF NOT IN SYSTYPES, GIVE UP
if @.objid is null
begin
select @.dbname=db_name()
raiserror(15009,-1,-1,@.objname,@.dbname)
return(1)
end|||Thanks ! I have all I need to check jobs still running !|||.. More or less :-(

insert into ##sp_help_job_table exec sp_help_job

Server: Msg 8164, Level 16, State 1, Procedure sp_get_composite_job_info, Line 67
An INSERT EXEC statement cannot be nested.|||Originally posted by Satya
MS discourages querying directly SYSTEM tables, I believe SP_HELP_JOB does give same information.

Since u said that, I was wondering why its discouraged? thx|||I am also discouraged of using system store procs...
No issue to my problem...|||"MS discourages querying directly SYSTEM tables, I believe SP_HELP_JOB does give same information."

Screw M$.

If they had their way we'd all be using wizards and nobody would have a clue what was going on in the background. "Pay no attention to the little man behind the curtain!"

Reference the system tables and you'll learn something about how Microsoft works. If a newly released version requires you to change your code, then learn how the new system works. I don't think that's a bad thing.

blindman|||ok...I can't find sp_help_job...where does it live?

never mind

I thought it was because you couldn't use temp tables with an EXEC...

but

CREATE TABLE wrk_sp_help_Job(
job_id varchar(255)
, job_name sysname
, job_aspect VARCHAR(9)
, job_type VARCHAR(12)
, owner_login_name sysname
, subsystem NVARCHAR(40)
, category_name sysname
, enabled TINYINT
, execution_status INT
, date_comparator CHAR(1)
, date_created DATETIME
, date_last_modified DATETIME
, [description] NVARCHAR(512)
)
GO

INSERT INTO wrk_sp_help_job EXEC msdb..sp_help_job

DROP TABLE wrk_sp_help_job

oesn't work either...it seems like since the sproc is calling other sprocs (nested) that it won't work...

gotta be a way...|||I remember looking into this little rat-hole before. I got as far as an extended stored procedure called xp_sqlagent_enum_jobs. The current run status is returned by this procedure, but you have to supply two parameters (at least on SP3). So the full syntax is:

master.dbo.xp_sqlagent_enum_jobs 1, 'sa'

This returns all of the jobs on my test server, but I do not have anything owned by regular users. I always yank the guest user out of MSDB, before letting any of the masses on to the box ;-).

Brett, you should be able to drop this into a temp table, then join that temp table back to sysjobs for readable names and the like.|||Wow...it's a dll

and it store the dates and times separately as char data...

You go M$, you go...

maybe I can sell donughts...sql

Wednesday, March 21, 2012

Run time jobs

A job is created to fetch data from source server and populate the
destination server. This job has the owner as windows authentication(user
account). This main job inturn creates sub jobs with owner as sa.
when i run the sub jobs from query analyser it works fine. But when ran from
sql server agent/jobs it is failing with the following error.
Msg 18456, Sev 14: Login failed for user 'CHNDomain\CHNSHL23456$'. [SQLS
TATE
28000]
Msg 7312, Sev 14: [SQLSTATE 01000].
[Note: CHNSHL23456$ is the destination system number]
when same job ran from query analyser that was logged using 'sa' account
fails with the following error.
Server: Msg 18456, Level 14, State 1, Line 1
Login failed for user 'sa'.
[OLE/DB provider returned message: Invalid connection string attribute]
The windows authenticated user ID exists in both source server/destination
server users list.
Pls hlp to get rid of this error.
Regards,
SSKSSK
Does the login have full pemissions? What is an account SQL Server Agent run
under?
"SSK" <SSK@.discussions.microsoft.com> wrote in message
news:CC9BF3BD-5394-40B1-A8E2-7D1DAC73BBA2@.microsoft.com...
>A job is created to fetch data from source server and populate the
> destination server. This job has the owner as windows authentication(user
> account). This main job inturn creates sub jobs with owner as sa.
> when i run the sub jobs from query analyser it works fine. But when ran
> from
> sql server agent/jobs it is failing with the following error.
> Msg 18456, Sev 14: Login failed for user 'CHNDomain\CHNSHL23456$'.
> [SQLSTATE
> 28000]
> Msg 7312, Sev 14: [SQLSTATE 01000].
> [Note: CHNSHL23456$ is the destination system number]
> when same job ran from query analyser that was logged using 'sa' account
> fails with the following error.
> Server: Msg 18456, Level 14, State 1, Line 1
> Login failed for user 'sa'.
> [OLE/DB provider returned message: Invalid connection string attribute
]
> The windows authenticated user ID exists in both source server/destination
> server users list.
> Pls hlp to get rid of this error.
> Regards,
> SSK
>|||What account is the SQL Agent service running under ? Jobs owned by sa will
access resources under the context of the SQL Agent service account.
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"SSK" <SSK@.discussions.microsoft.com> wrote in message
news:CC9BF3BD-5394-40B1-A8E2-7D1DAC73BBA2@.microsoft.com...
>A job is created to fetch data from source server and populate the
> destination server. This job has the owner as windows authentication(user
> account). This main job inturn creates sub jobs with owner as sa.
> when i run the sub jobs from query analyser it works fine. But when ran
> from
> sql server agent/jobs it is failing with the following error.
> Msg 18456, Sev 14: Login failed for user 'CHNDomain\CHNSHL23456$'.
> [SQLSTATE
> 28000]
> Msg 7312, Sev 14: [SQLSTATE 01000].
> [Note: CHNSHL23456$ is the destination system number]
> when same job ran from query analyser that was logged using 'sa' account
> fails with the following error.
> Server: Msg 18456, Level 14, State 1, Line 1
> Login failed for user 'sa'.
> [OLE/DB provider returned message: Invalid connection string attribute
]
> The windows authenticated user ID exists in both source server/destination
> server users list.
> Pls hlp to get rid of this error.
> Regards,
> SSK
>|||The SQL server agent is started by Local System account.
The login account has admin privileges on source and destination server als
o.
"Jasper Smith" wrote:

> What account is the SQL Agent service running under ? Jobs owned by sa wil
l
> access resources under the context of the SQL Agent service account.
> --
> HTH
> Jasper Smith (SQL Server MVP)
> http://www.sqldbatips.com
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "SSK" <SSK@.discussions.microsoft.com> wrote in message
> news:CC9BF3BD-5394-40B1-A8E2-7D1DAC73BBA2@.microsoft.com...
>
>|||Local System does not have access to network resources. If
you are accessing other servers, you need to use a domain
account for the service with the appropriate permissions.
-Sue
On Wed, 24 Aug 2005 23:33:09 -0700, SSK
<SSK@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>The SQL server agent is started by Local System account.
>The login account has admin privileges on source and destination server al
so.
>"Jasper Smith" wrote:
>

Tuesday, March 20, 2012

Run sp when job fails

I have a few backup jobs of SQL 2000 databases that are scheduled and run
via SQL Agent. Is it possible to have SQL Server run a stored procedure if
a job fails? I only saw options for emailing but that required mail
profiles, etc. Thanks.
David
>I have a few backup jobs of SQL 2000 databases that are scheduled and run
>via SQL Agent. Is it possible to have SQL Server run a stored procedure if
>a job fails?
Sure, create the job with two steps. Step 1 does the bulk of your work. It
is set to quit the job with success, or move to the next step on failure.
The next step (which only gets reached if step 1 fails) can call your stored
procedure, send an e-mail, etc.
A

Run sp when job fails

I have a few backup jobs of SQL 2000 databases that are scheduled and run
via SQL Agent. Is it possible to have SQL Server run a stored procedure if
a job fails? I only saw options for emailing but that required mail
profiles, etc. Thanks.
David>I have a few backup jobs of SQL 2000 databases that are scheduled and run
>via SQL Agent. Is it possible to have SQL Server run a stored procedure if
>a job fails?
Sure, create the job with two steps. Step 1 does the bulk of your work. It
is set to quit the job with success, or move to the next step on failure.
The next step (which only gets reached if step 1 fails) can call your stored
procedure, send an e-mail, etc.
A

Run sp when job fails

I have a few backup jobs of SQL 2000 databases that are scheduled and run
via SQL Agent. Is it possible to have SQL Server run a stored procedure if
a job fails? I only saw options for emailing but that required mail
profiles, etc. Thanks.
David>I have a few backup jobs of SQL 2000 databases that are scheduled and run
>via SQL Agent. Is it possible to have SQL Server run a stored procedure if
>a job fails?
Sure, create the job with two steps. Step 1 does the bulk of your work. It
is set to quit the job with success, or move to the next step on failure.
The next step (which only gets reached if step 1 fails) can call your stored
procedure, send an e-mail, etc.
A

Run Single Step In Job on SQL Server 2000

I am working in an environment where application devs don't have the
ability to run SQL Server Jobs that are setup already in production.
Our jobs are multi-step and have a lot of steps. What I am looking for
is a way for the operators who have privileges in production but know
nothing about SQL Server to run a single step inside of a job without
triggering other steps. SQL Server 2000 allows for the ability to
start a job at a certain step but what I want to happen is for only
that particular step to run. Any thoughts?
SpencerBecause of the seperation of duties in the organization I am also
looking at creating an "On Demand" job that application devs will have
privileges to update a particular .sql file and then put in a runsheet
to have operations kick off the on demand job. What I do want the on
demand job to do however is do some logging such as who kicked the job
off, what sql ended up being executed, rows affected, etc. Maybe an
email as well. I know there have got to be lots of environments doing
something similar.
Spencer|||On 11 May 2006 18:21:08 -0700, "stabbert" <spencer@.tabbert.net> wrote:
>I am working in an environment where application devs don't have the
>ability to run SQL Server Jobs that are setup already in production.
>Our jobs are multi-step and have a lot of steps. What I am looking for
>is a way for the operators who have privileges in production but know
>nothing about SQL Server to run a single step inside of a job without
>triggering other steps. SQL Server 2000 allows for the ability to
>start a job at a certain step but what I want to happen is for only
>that particular step to run. Any thoughts?
>Spencer
It's possible to create code that parses out the job step and creates
a new job that you can then run immediately, but short of something
zippy like this, I don't know how else you could do it.
Josh

Run Single Step In Job on SQL Server 2000

I am working in an environment where application devs don't have the
ability to run SQL Server Jobs that are setup already in production.
Our jobs are multi-step and have a lot of steps. What I am looking for
is a way for the operators who have privileges in production but know
nothing about SQL Server to run a single step inside of a job without
triggering other steps. SQL Server 2000 allows for the ability to
start a job at a certain step but what I want to happen is for only
that particular step to run. Any thoughts?
SpencerBecause of the seperation of duties in the organization I am also
looking at creating an "On Demand" job that application devs will have
privileges to update a particular .sql file and then put in a runsheet
to have operations kick off the on demand job. What I do want the on
demand job to do however is do some logging such as who kicked the job
off, what sql ended up being executed, rows affected, etc. Maybe an
email as well. I know there have got to be lots of environments doing
something similar.
Spencer|||On 11 May 2006 18:21:08 -0700, "stabbert" <spencer@.tabbert.net> wrote:
>I am working in an environment where application devs don't have the
>ability to run SQL Server Jobs that are setup already in production.
>Our jobs are multi-step and have a lot of steps. What I am looking for
>is a way for the operators who have privileges in production but know
>nothing about SQL Server to run a single step inside of a job without
>triggering other steps. SQL Server 2000 allows for the ability to
>start a job at a certain step but what I want to happen is for only
>that particular step to run. Any thoughts?
>Spencer
It's possible to create code that parses out the job step and creates
a new job that you can then run immediately, but short of something
zippy like this, I don't know how else you could do it.
Josh

Monday, March 12, 2012

Run jobs in SELECT CASE?

Hello!
Is that possible to call a job using SELECT CASE statement? I am trying
to run some jobs based on some cases in my stored procedure. See below
the code:
select case RptName
when 'A' then [msdb].[dbo].[sp_start_job] @.job_name = 'A'
when 'B' then [msdb].[dbo].[sp_start_job] @.job_name = 'B'
when 'C' then [msdb].[dbo].[sp_start_job] @.job_name = 'C'
when 'D' then [msdb].[dbo].[sp_start_job] @.job_name = 'D'
end
from Table
Trying not to use IF-ELSE statement (which I have tried and it is
working fine).
Thanks for your help!
*** Sent via Developersdex http://www.examnotes.net ***>> Trying not to use IF-ELSE statement
SELECT statement returns a resultset, it is not not meant to execute
procedures. CASE is not supposed to be used as you have suggested. It
returns a scalar value.
Each sp_start_job invocation is a separate statement. Use IF.. ELSE
construct to execute them conditionally.
Anith|||In T-SQL, there is no [select case ..] statement. Instead, [case.. when..
then.. end] is an expression, so you can't execute a procedure from it, but
you can call functions.
However, this would seem to do what you want:
select @.RptName = RptName from Table
if @.RptName = 'A' exec sp_start_job @.job_name = 'A'
if @.RptName = 'B' exec sp_start_job @.job_name = 'B'
Or, looking at your example, it seems that perhaps just this would work:
exec sp_start_job @.job_name = @.RptName
"Test Test" <farooqhs_2000@.yahoo.com> wrote in message
news:eWaWmjaBGHA.1864@.TK2MSFTNGP12.phx.gbl...
> Hello!
> Is that possible to call a job using SELECT CASE statement? I am trying
> to run some jobs based on some cases in my stored procedure. See below
> the code:
> select case RptName
> when 'A' then [msdb].[dbo].[sp_start_job] @.job_name = 'A'
> when 'B' then [msdb].[dbo].[sp_start_job] @.job_name = 'B'
> when 'C' then [msdb].[dbo].[sp_start_job] @.job_name = 'C'
> when 'D' then [msdb].[dbo].[sp_start_job] @.job_name = 'D'
> end
> from Table
> Trying not to use IF-ELSE statement (which I have tried and it is
> working fine).
> Thanks for your help!
>
> *** Sent via Developersdex http://www.examnotes.net ***|||Thanks, Anith.
*** Sent via Developersdex http://www.examnotes.net ***|||But then so would...
select @.RptName = RptName from Table
exec sp_start_job @.job_name = @.RptName
Just remember to keep the RptName matching the Job name.
Colin Dawson
www.cjdawson.com
"JT" <someone@.microsoft.com> wrote in message
news:OwGor8aBGHA.1864@.TK2MSFTNGP12.phx.gbl...
> In T-SQL, there is no [select case ..] statement. Instead, [case.. when..
> then.. end] is an expression, so you can't execute a procedure from it,
> but you can call functions.
> However, this would seem to do what you want:
> select @.RptName = RptName from Table
> if @.RptName = 'A' exec sp_start_job @.job_name = 'A'
> if @.RptName = 'B' exec sp_start_job @.job_name = 'B'
> Or, looking at your example, it seems that perhaps just this would work:
> exec sp_start_job @.job_name = @.RptName
>
> "Test Test" <farooqhs_2000@.yahoo.com> wrote in message
> news:eWaWmjaBGHA.1864@.TK2MSFTNGP12.phx.gbl...
>

Friday, March 9, 2012

Run DTS from SQL server jobs..

Hi is it possible to run multiple DTS from a SQL server
job? I tried the SQL enterprise manager wizard to build a
job but it does not allow me to select a DTS job. Am I
doing anything wrong?You can schedule multiple packages to run from one job. Manually edit the
job, and add as many Operating system command steps as there are DTS
pacakges to run. You can use the dtsrunui.exe to get the proper command
line using the advanced button in the user interface. It can generate the
command line for you, and you can copy paste it into the job step.
Simon Worth
"Yaheya Quazi" <yquazi@.ucmerced.edu> wrote in message
news:5c4501c52400$71c39450$a401280a@.phx.gbl...
> Hi is it possible to run multiple DTS from a SQL server
> job? I tried the SQL enterprise manager wizard to build a
> job but it does not allow me to select a DTS job. Am I
> doing anything wrong?|||See the post a few items down titled Calling a DTS job thru a Stored
Procedure. That would allow you to specify as many jobs as you like.
"Yaheya Quazi" wrote:

> Hi is it possible to run multiple DTS from a SQL server
> job? I tried the SQL enterprise manager wizard to build a
> job but it does not allow me to select a DTS job. Am I
> doing anything wrong?
>