Showing posts with label cmdexec. Show all posts
Showing posts with label cmdexec. Show all posts

Friday, March 30, 2012

Scheduling sqlcmd script in sql agent

Is it possible to schedule a sqlcmd script within sqlagent? That is without running a cmdexec?

Thanks,

what is the actual requirement ... its not clear. you can use XP_cmdshell to execute sqlcmd script from SQL envriornment

Else you can use windows scheduler to execute the sqlcmd script file

Madhu

|||

I was hoping that we could run a sqlcmd script in a normal agent job, similar to the ability to run them in sql management studio window. The advantage of doing that is, the entire solution is in one place.

From your email it sounds as if, there is no way to do this and the only choice is to run a cmdshell agent job or to schedule in the Windows scheduler.

|||

In the Job Step Properties window, in the [General], click on [Type].

There you can select [Operation System ...]

Put your script there.

(

SQLCmd runs SQL commands in the OS environment,

CMDExec runs OS commands in the SQL Server environment -including SQLCmd.exe.

)

However, if you 'should' be able to directly run SQLCmd script as a Job step.

If you posted the command line, we may be able to better advise you about the most efficient method to accomplish your task.

Tuesday, March 20, 2012

Scheduled Job Sometimes Error Sometimes Not

I have a scheduled job contain 2 steps. Step 1 is execute DTS Package
using CmdExec 'DTSRun', step 2 using TSQL to execute just simple query.
This job execute recurely every day, every 6 hours.
The problem is, sometimes this job was successfull, but sometimes
failed with error as below :

...
...
Process Exit Code -1073741819. The step failed.

Please help me, what the cause of the error?
Any help would be greatly appreciated.Resant (resant_v@.yahoo.com) writes:
> I have a scheduled job contain 2 steps. Step 1 is execute DTS Package
> using CmdExec 'DTSRun', step 2 using TSQL to execute just simple query.
> This job execute recurely every day, every 6 hours.
> The problem is, sometimes this job was successfull, but sometimes
> failed with error as below :
> ...
> ...
> Process Exit Code -1073741819. The step failed.
> Please help me, what the cause of the error?
> Any help would be greatly appreciated.

In View Job History, there is a check box for "Show step details". Check
that box, and you may find some more details.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks for your reply.
The error that I've post is taken after I've checked "Show step
details". OK, I'll post the error again completely :

Executed as user: XXXX\xxxx. ...un OnStart:
DTSStep_DTSExecuteSQLTask_6 DTSRun OnFinish:
DTSStep_DTSExecuteSQLTask_6 DTSRun OnStart:
DTSStep_DTSExecuteSQLTask_10 DTSRun OnFinish:
DTSStep_DTSExecuteSQLTask_10 DTSRun OnStart:
DTSStep_DTSDataPumpTask_1 DTSRun OnStart: DTSStep_DTSDataPumpTask_2
DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
DTSStep_DTSDataPumpTask_3 DTSRun OnStart: DTSStep_DTSDataPumpTask_2
DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTS... Process
Exit Code -1073741819. The step failed.|||Resant (resant_v@.yahoo.com) writes:
> Thanks for your reply.
> The error that I've post is taken after I've checked "Show step
> details". OK, I'll post the error again completely :
> Executed as user: XXXX\xxxx. ...un OnStart:
> DTSStep_DTSExecuteSQLTask_6 DTSRun OnFinish:
> DTSStep_DTSExecuteSQLTask_6 DTSRun OnStart:
> DTSStep_DTSExecuteSQLTask_10 DTSRun OnFinish:
> DTSStep_DTSExecuteSQLTask_10 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_1 DTSRun OnStart: DTSStep_DTSDataPumpTask_2
> DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_3 DTSRun OnStart: DTSStep_DTSDataPumpTask_2
> DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
> DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
> DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
> DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTS... Process
> Exit Code -1073741819. The step failed.

That's pretty anonymous. Unfortunately I don't know DTS, so I don't
have any suggestions to offer. Maybe the people in
microsoft.public.sqlserver.dts has any ideas.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Some Googling suggests that the error may be caused by a Windows bug:

http://support.microsoft.com/defaul...kb;EN-US;306497
http://groups-beta.google.com/group...lr=&sa=N&tab=wg

If you don't already have the latest servicepacks for Windows and
MSSQL, it would probably be worth installing them to see if that
resolves the issue. Since a few people seem to have seen this error in
connection with a virus infection, that would be something else to
check. If this doesn't help, then it might be worth calling Microsoft.

Simon

Saturday, February 25, 2012

Schedule cmdExec

How can I schedule a exe program from SQL server jobs ?
What is the CmdExec command I need to put in in order to
run a exe program call Test.exeJust put in the name and path to the exec file, like below:
C:\test.exe
Note that this file is executed on the *server*. Also, the program cannot open any windows (it need
to be a what we call "console" program).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Travis" <anonymous@.discussions.microsoft.com> wrote in message
news:135601c4ad16$9b197880$a301280a@.phx.gbl...
> How can I schedule a exe program from SQL server jobs ?
> What is the CmdExec command I need to put in in order to
> run a exe program call Test.exe|||My test.exe is created using vb6 for doing some extra
process.
I already try the "C:\Test.exe" but it not runnable.
>--Original Message--
>Just put in the name and path to the exec file, like
below:
>C:\test.exe
>Note that this file is executed on the *server*. Also,
the program cannot open any windows (it need
>to be a what we call "console" program).
>--
>Tibor Karaszi, SQL Server MVP
>http://www.karaszi.com/sqlserver/default.asp
>http://www.solidqualitylearning.com/
>
>"Travis" <anonymous@.discussions.microsoft.com> wrote in
message
>news:135601c4ad16$9b197880$a301280a@.phx.gbl...
>> How can I schedule a exe program from SQL server jobs ?
>> What is the CmdExec command I need to put in in order
to
>> run a exe program call Test.exe
>
>.
>|||If you right-click the job and select "history", and in this dialog check "View Step Details", what
do you have for your jobstep?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Travis" <anonymous@.discussions.microsoft.com> wrote in message
news:283a01c4ad1c$700546a0$a601280a@.phx.gbl...
> My test.exe is created using vb6 for doing some extra
> process.
> I already try the "C:\Test.exe" but it not runnable.
>>--Original Message--
>>Just put in the name and path to the exec file, like
> below:
>>C:\test.exe
>>Note that this file is executed on the *server*. Also,
> the program cannot open any windows (it need
>>to be a what we call "console" program).
>>--
>>Tibor Karaszi, SQL Server MVP
>>http://www.karaszi.com/sqlserver/default.asp
>>http://www.solidqualitylearning.com/
>>
>>"Travis" <anonymous@.discussions.microsoft.com> wrote in
> message
>>news:135601c4ad16$9b197880$a301280a@.phx.gbl...
>> How can I schedule a exe program from SQL server jobs ?
>> What is the CmdExec command I need to put in in order
> to
>> run a exe program call Test.exe
>>
>>.|||When I check on the Windows Task Manager,I notice that the
program was start up but I don't know why it is not
runnable.
No jobs history is available because the program already
been executed but I'm sure the program it not run the
process because it takes very long time to execute
and I not get the desired result I need.
If I run the Test.exe manually , it takes about few seconds
to finish the process.
I need to manually terminate the Job since it seems like
hanging there.
Any other setting I need to configure ?
TQ for your info
>--Original Message--
>If you right-click the job and select "history", and in
this dialog check "View Step Details", what
>do you have for your jobstep?
>--
>Tibor Karaszi, SQL Server MVP
>http://www.karaszi.com/sqlserver/default.asp
>http://www.solidqualitylearning.com/
>
>"Travis" <anonymous@.discussions.microsoft.com> wrote in
message
>news:283a01c4ad1c$700546a0$a601280a@.phx.gbl...
>> My test.exe is created using vb6 for doing some extra
>> process.
>> I already try the "C:\Test.exe" but it not runnable.
>>--Original Message--
>>Just put in the name and path to the exec file, like
>> below:
>>C:\test.exe
>>Note that this file is executed on the *server*. Also,
>> the program cannot open any windows (it need
>>to be a what we call "console" program).
>>--
>>Tibor Karaszi, SQL Server MVP
>>http://www.karaszi.com/sqlserver/default.asp
>>http://www.solidqualitylearning.com/
>>
>>"Travis" <anonymous@.discussions.microsoft.com> wrote in
>> message
>>news:135601c4ad16$9b197880$a301280a@.phx.gbl...
>> How can I schedule a exe program from SQL server
jobs ?
>> What is the CmdExec command I need to put in in order
>> to
>> run a exe program call Test.exe
>>
>>.
>
>.
>|||Are you 100% certain that the program doesn't display any window, or message box?`The symptoms you
describe is exactly what we see if we try starting programs that tries to display windows...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<anonymous@.discussions.microsoft.com> wrote in message
news:287301c4af7c$e0e05420$a301280a@.phx.gbl...
> When I check on the Windows Task Manager,I notice that the
> program was start up but I don't know why it is not
> runnable.
> No jobs history is available because the program already
> been executed but I'm sure the program it not run the
> process because it takes very long time to execute
> and I not get the desired result I need.
> If I run the Test.exe manually , it takes about few seconds
> to finish the process.
> I need to manually terminate the Job since it seems like
> hanging there.
> Any other setting I need to configure ?
> TQ for your info
>>--Original Message--
>>If you right-click the job and select "history", and in
> this dialog check "View Step Details", what
>>do you have for your jobstep?
>>--
>>Tibor Karaszi, SQL Server MVP
>>http://www.karaszi.com/sqlserver/default.asp
>>http://www.solidqualitylearning.com/
>>
>>"Travis" <anonymous@.discussions.microsoft.com> wrote in
> message
>>news:283a01c4ad1c$700546a0$a601280a@.phx.gbl...
>> My test.exe is created using vb6 for doing some extra
>> process.
>> I already try the "C:\Test.exe" but it not runnable.
>>--Original Message--
>>Just put in the name and path to the exec file, like
>> below:
>>C:\test.exe
>>Note that this file is executed on the *server*. Also,
>> the program cannot open any windows (it need
>>to be a what we call "console" program).
>>--
>>Tibor Karaszi, SQL Server MVP
>>http://www.karaszi.com/sqlserver/default.asp
>>http://www.solidqualitylearning.com/
>>
>>"Travis" <anonymous@.discussions.microsoft.com> wrote in
>> message
>>news:135601c4ad16$9b197880$a301280a@.phx.gbl...
>> How can I schedule a exe program from SQL server
> jobs ?
>> What is the CmdExec command I need to put in in order
>> to
>> run a exe program call Test.exe
>>
>>.
>>
>>.|||I m sure the program did not process ...because my program will just take few
seconds to complete and will display a msgbox after that ..
I wait for few minutes after execute the jobs but it seems like no process..
what is other posibility to cause it ?
"Tibor Karaszi" wrote:
> Are you 100% certain that the program doesn't display any window, or message box?`The symptoms you
> describe is exactly what we see if we try starting programs that tries to display windows...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> <anonymous@.discussions.microsoft.com> wrote in message
> news:287301c4af7c$e0e05420$a301280a@.phx.gbl...
> > When I check on the Windows Task Manager,I notice that the
> > program was start up but I don't know why it is not
> > runnable.
> >
> > No jobs history is available because the program already
> > been executed but I'm sure the program it not run the
> > process because it takes very long time to execute
> > and I not get the desired result I need.
> >
> > If I run the Test.exe manually , it takes about few seconds
> > to finish the process.
> >
> > I need to manually terminate the Job since it seems like
> > hanging there.
> >
> > Any other setting I need to configure ?
> >
> > TQ for your info
> >
> >>--Original Message--
> >>If you right-click the job and select "history", and in
> > this dialog check "View Step Details", what
> >>do you have for your jobstep?
> >>
> >>--
> >>Tibor Karaszi, SQL Server MVP
> >>http://www.karaszi.com/sqlserver/default.asp
> >>http://www.solidqualitylearning.com/
> >>
> >>
> >>"Travis" <anonymous@.discussions.microsoft.com> wrote in
> > message
> >>news:283a01c4ad1c$700546a0$a601280a@.phx.gbl...
> >> My test.exe is created using vb6 for doing some extra
> >> process.
> >> I already try the "C:\Test.exe" but it not runnable.
> >>
> >>--Original Message--
> >>Just put in the name and path to the exec file, like
> >> below:
> >>
> >>C:\test.exe
> >>
> >>Note that this file is executed on the *server*. Also,
> >> the program cannot open any windows (it need
> >>to be a what we call "console" program).
> >>
> >>--
> >>Tibor Karaszi, SQL Server MVP
> >>http://www.karaszi.com/sqlserver/default.asp
> >>http://www.solidqualitylearning.com/
> >>
> >>
> >>"Travis" <anonymous@.discussions.microsoft.com> wrote in
> >> message
> >>news:135601c4ad16$9b197880$a301280a@.phx.gbl...
> >> How can I schedule a exe program from SQL server
> > jobs ?
> >> What is the CmdExec command I need to put in in order
> >> to
> >> run a exe program call Test.exe
> >>
> >>
> >>.
> >>
> >>
> >>
> >>.
> >>
>
>|||If the program completes and displays a message box then it
does have a window or message box displaying. The command
will appear to hang but it is actually waiting for a
response to the message box or can't create the window. A
service such as SQL Server or SQL Server Agent can't respond
to user input (such as clicking the ok button on a message
box). You need to remove the message box. The exe can't have
any windows or user input.
-Sue
On Mon, 11 Oct 2004 19:49:07 -0700, Travis
<Travis@.discussions.microsoft.com> wrote:
>I m sure the program did not process ...because my program will just take few
>seconds to complete and will display a msgbox after that ..
>I wait for few minutes after execute the jobs but it seems like no process..
>what is other posibility to cause it ?
>"Tibor Karaszi" wrote:
>> Are you 100% certain that the program doesn't display any window, or message box?`The symptoms you
>> describe is exactly what we see if we try starting programs that tries to display windows...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> <anonymous@.discussions.microsoft.com> wrote in message
>> news:287301c4af7c$e0e05420$a301280a@.phx.gbl...
>> > When I check on the Windows Task Manager,I notice that the
>> > program was start up but I don't know why it is not
>> > runnable.
>> >
>> > No jobs history is available because the program already
>> > been executed but I'm sure the program it not run the
>> > process because it takes very long time to execute
>> > and I not get the desired result I need.
>> >
>> > If I run the Test.exe manually , it takes about few seconds
>> > to finish the process.
>> >
>> > I need to manually terminate the Job since it seems like
>> > hanging there.
>> >
>> > Any other setting I need to configure ?
>> >
>> > TQ for your info
>> >
>> >>--Original Message--
>> >>If you right-click the job and select "history", and in
>> > this dialog check "View Step Details", what
>> >>do you have for your jobstep?
>> >>
>> >>--
>> >>Tibor Karaszi, SQL Server MVP
>> >>http://www.karaszi.com/sqlserver/default.asp
>> >>http://www.solidqualitylearning.com/
>> >>
>> >>
>> >>"Travis" <anonymous@.discussions.microsoft.com> wrote in
>> > message
>> >>news:283a01c4ad1c$700546a0$a601280a@.phx.gbl...
>> >> My test.exe is created using vb6 for doing some extra
>> >> process.
>> >> I already try the "C:\Test.exe" but it not runnable.
>> >>
>> >>--Original Message--
>> >>Just put in the name and path to the exec file, like
>> >> below:
>> >>
>> >>C:\test.exe
>> >>
>> >>Note that this file is executed on the *server*. Also,
>> >> the program cannot open any windows (it need
>> >>to be a what we call "console" program).
>> >>
>> >>--
>> >>Tibor Karaszi, SQL Server MVP
>> >>http://www.karaszi.com/sqlserver/default.asp
>> >>http://www.solidqualitylearning.com/
>> >>
>> >>
>> >>"Travis" <anonymous@.discussions.microsoft.com> wrote in
>> >> message
>> >>news:135601c4ad16$9b197880$a301280a@.phx.gbl...
>> >> How can I schedule a exe program from SQL server
>> > jobs ?
>> >> What is the CmdExec command I need to put in in order
>> >> to
>> >> run a exe program call Test.exe
>> >>
>> >>
>> >>.
>> >>
>> >>
>> >>
>> >>.
>> >>
>>

Schedule cmdExec

How can I schedule a exe program from SQL server jobs ?
What is the CmdExec command I need to put in in order to
run a exe program call Test.exe
Just put in the name and path to the exec file, like below:
C:\test.exe
Note that this file is executed on the *server*. Also, the program cannot open any windows (it need
to be a what we call "console" program).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Travis" <anonymous@.discussions.microsoft.com> wrote in message
news:135601c4ad16$9b197880$a301280a@.phx.gbl...
> How can I schedule a exe program from SQL server jobs ?
> What is the CmdExec command I need to put in in order to
> run a exe program call Test.exe
|||My test.exe is created using vb6 for doing some extra
process.
I already try the "C:\Test.exe" but it not runnable.

>--Original Message--
>Just put in the name and path to the exec file, like
below:
>C:\test.exe
>Note that this file is executed on the *server*. Also,
the program cannot open any windows (it need
>to be a what we call "console" program).
>--
>Tibor Karaszi, SQL Server MVP
>http://www.karaszi.com/sqlserver/default.asp
>http://www.solidqualitylearning.com/
>
>"Travis" <anonymous@.discussions.microsoft.com> wrote in
message[vbcol=seagreen]
>news:135601c4ad16$9b197880$a301280a@.phx.gbl...
to
>
>.
>
|||If you right-click the job and select "history", and in this dialog check "View Step Details", what
do you have for your jobstep?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Travis" <anonymous@.discussions.microsoft.com> wrote in message
news:283a01c4ad1c$700546a0$a601280a@.phx.gbl...[vbcol=seagreen]
> My test.exe is created using vb6 for doing some extra
> process.
> I already try the "C:\Test.exe" but it not runnable.
> below:
> the program cannot open any windows (it need
> message
> to
|||When I check on the Windows Task Manager,I notice that the
program was start up but I don't know why it is not
runnable.
No jobs history is available because the program already
been executed but I'm sure the program it not run the
process because it takes very long time to execute
and I not get the desired result I need.
If I run the Test.exe manually , it takes about few seconds
to finish the process.
I need to manually terminate the Job since it seems like
hanging there.
Any other setting I need to configure ?
TQ for your info

>--Original Message--
>If you right-click the job and select "history", and in
this dialog check "View Step Details", what
>do you have for your jobstep?
>--
>Tibor Karaszi, SQL Server MVP
>http://www.karaszi.com/sqlserver/default.asp
>http://www.solidqualitylearning.com/
>
>"Travis" <anonymous@.discussions.microsoft.com> wrote in
message[vbcol=seagreen]
>news:283a01c4ad1c$700546a0$a601280a@.phx.gbl...
jobs ?
>
>.
>
|||Are you 100% certain that the program doesn't display any window, or message box?`The symptoms you
describe is exactly what we see if we try starting programs that tries to display windows...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<anonymous@.discussions.microsoft.com> wrote in message
news:287301c4af7c$e0e05420$a301280a@.phx.gbl...[vbcol=seagreen]
> When I check on the Windows Task Manager,I notice that the
> program was start up but I don't know why it is not
> runnable.
> No jobs history is available because the program already
> been executed but I'm sure the program it not run the
> process because it takes very long time to execute
> and I not get the desired result I need.
> If I run the Test.exe manually , it takes about few seconds
> to finish the process.
> I need to manually terminate the Job since it seems like
> hanging there.
> Any other setting I need to configure ?
> TQ for your info
> this dialog check "View Step Details", what
> message
> jobs ?
|||If the program completes and displays a message box then it
does have a window or message box displaying. The command
will appear to hang but it is actually waiting for a
response to the message box or can't create the window. A
service such as SQL Server or SQL Server Agent can't respond
to user input (such as clicking the ok button on a message
box). You need to remove the message box. The exe can't have
any windows or user input.
-Sue
On Mon, 11 Oct 2004 19:49:07 -0700, Travis
<Travis@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>I m sure the program did not process ...because my program will just take few
>seconds to complete and will display a msgbox after that ..
>I wait for few minutes after execute the jobs but it seems like no process..
>what is other posibility to cause it ?
>"Tibor Karaszi" wrote: