Showing posts with label bat. Show all posts
Showing posts with label bat. 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.

Monday, March 26, 2012

Running a .rpt file from dos

Can someone tell me if it's possible to run a CR .rpt file from the MS DOS command line? I'd like to run it (in a .bat file) and then save the output, to disc.I wonder if there is a way to do this
Why dont you use Export functionality?|||Hello Madhi: Can you elaborate on your idea? How would I invoke the Export functionality, from DOS?|||Open the report and from export option export the data|||What syntax do I use? I want to do this from the command line, not from within the IDE.

Monday, March 12, 2012

Run IN PROCESS

Sorry but how do you configure to run IN PROCESS. My task runs like this in a BAT file

dtexec /f "\\ssssagemet\xteurs\Admin\FC\Test\DTSX\Test_Alex\Rename_file_alex.dtsx"

Thanks,

aL.

What is the issue, exactly?

Wednesday, March 7, 2012

run backup (maintenance plan) from Batch (.bat) file

What is the method to execute backups from batch (.bat) files on the server running SQL Server. I have tried the sqlmaint command - doesn't seem to execute, looked into the xp_sqlmaint with no luck. I'm sure the problem lies in my lack of DOS batch programming skills. If anyone has an example of a batch file that executes a backup would you mind sharing. thanksHave you tried using OSQL from within a batch file?|||just stumbled onto that option this morning. I'm not much of a SQL guru, tring to set up some backups of DB contained in SQL from an COTS package. Do you know how this would all fit together? It appears I would create a file with (possiblely) the SQLMAINT (statement and parms) contained within. Then execute it from within the OSQL statement. Does this sound like I'm on the right track? Do you use the OSQL statement in any .BAT files? I would love to see an example of a (.BAT & sqlmaint) file that I could mimic the context of.|||personally I do not use maintenance plans. I script out all of my maintenance using BACKUP and DBCC t-sql statements. And yu can probably do this with osql in a batch file.

Why may I ask are you taking this approach? Do you need to schedule these to run at a specific time? If so, why not use a sql server agent job?|||I want to have it executed by the server backup software right before the backup system: tivoli, TSM, (not sure of the specific tool) runs. I also want to include some file ZIPs and versioning (file rolls - moves - to specific folders) to mimic the backup/DR process used for other products on the server (a comprehebnsive backup/recovery porocess used for our COTS tools)|||you can use jobs in the sql server agent to do all of that. I would go to SQL Server books Online-->Contents-->Administering SQL Server--> Automating Administrative Tasks-->Implimenting Jobs and do some reading.

you may also want to read xp_cmdshell for the file copies|||thanks I will...I just can't believe that there isn't a fairly easy way to do it extrnally so that I can leverage my existing BAT files and scheduling software (autosys)

Run a Maint Plan from a bat file?

Is it possible to run a Maintenance Plan Job called from a bat file?
I need to have a Perl script finish running its job before the Maintenance
Plan is called so there's no interference because of the locked tables while
doing the reindexing.
I can run the Perl script from a bat file so it would be great if I could
have the 2nd line of the bat file call the Maint Plan.
SQL 2000
Any insight or suggestions appreciated.
Don
Sure. You can call OSQL.EXE and in there execute sp_start_job.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"donsql22222" <donsql22222@.discussions.microsoft.com> wrote in message
news:4E296E58-70FA-4E0A-BDE3-3D673B462763@.microsoft.com...
> Is it possible to run a Maintenance Plan Job called from a bat file?
> I need to have a Perl script finish running its job before the Maintenance
> Plan is called so there's no interference because of the locked tables while
> doing the reindexing.
> I can run the Perl script from a bat file so it would be great if I could
> have the 2nd line of the bat file call the Maint Plan.
> SQL 2000
> Any insight or suggestions appreciated.
> Don
|||ahhhh...beautiful!!
thx!
Don
"Tibor Karaszi" wrote:

> Sure. You can call OSQL.EXE and in there execute sp_start_job.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "donsql22222" <donsql22222@.discussions.microsoft.com> wrote in message
> news:4E296E58-70FA-4E0A-BDE3-3D673B462763@.microsoft.com...
>

Run a Maint Plan from a bat file?

Is it possible to run a Maintenance Plan Job called from a bat file?
I need to have a PERL script finish running its job before the Maintenance
Plan is called so there's no interference because of the locked tables while
doing the reindexing.
I can run the PERL script from a bat file so it would be great if I could
have the 2nd line of the bat file call the Maint Plan.
SQL 2000
Any insight or suggestions appreciated.
DonSure. You can call OSQL.EXE and in there execute sp_start_job.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"donsql22222" <donsql22222@.discussions.microsoft.com> wrote in message
news:4E296E58-70FA-4E0A-BDE3-3D673B462763@.microsoft.com...
> Is it possible to run a Maintenance Plan Job called from a bat file?
> I need to have a PERL script finish running its job before the Maintenance
> Plan is called so there's no interference because of the locked tables whi
le
> doing the reindexing.
> I can run the PERL script from a bat file so it would be great if I could
> have the 2nd line of the bat file call the Maint Plan.
> SQL 2000
> Any insight or suggestions appreciated.
> Don|||ahhhh...beautiful!!
thx!
Don
"Tibor Karaszi" wrote:

> Sure. You can call OSQL.EXE and in there execute sp_start_job.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "donsql22222" <donsql22222@.discussions.microsoft.com> wrote in message
> news:4E296E58-70FA-4E0A-BDE3-3D673B462763@.microsoft.com...
>

Run a Maint Plan from a bat file?

Is it possible to run a Maintenance Plan Job called from a bat file?
I need to have a Perl script finish running its job before the Maintenance
Plan is called so there's no interference because of the locked tables while
doing the reindexing.
I can run the Perl script from a bat file so it would be great if I could
have the 2nd line of the bat file call the Maint Plan.
SQL 2000
Any insight or suggestions appreciated.
DonSure. You can call OSQL.EXE and in there execute sp_start_job.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"donsql22222" <donsql22222@.discussions.microsoft.com> wrote in message
news:4E296E58-70FA-4E0A-BDE3-3D673B462763@.microsoft.com...
> Is it possible to run a Maintenance Plan Job called from a bat file?
> I need to have a Perl script finish running its job before the Maintenance
> Plan is called so there's no interference because of the locked tables while
> doing the reindexing.
> I can run the Perl script from a bat file so it would be great if I could
> have the 2nd line of the bat file call the Maint Plan.
> SQL 2000
> Any insight or suggestions appreciated.
> Don|||ahhhh...beautiful!!
thx!
Don
"Tibor Karaszi" wrote:
> Sure. You can call OSQL.EXE and in there execute sp_start_job.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "donsql22222" <donsql22222@.discussions.microsoft.com> wrote in message
> news:4E296E58-70FA-4E0A-BDE3-3D673B462763@.microsoft.com...
> > Is it possible to run a Maintenance Plan Job called from a bat file?
> >
> > I need to have a Perl script finish running its job before the Maintenance
> > Plan is called so there's no interference because of the locked tables while
> > doing the reindexing.
> >
> > I can run the Perl script from a bat file so it would be great if I could
> > have the 2nd line of the bat file call the Maint Plan.
> >
> > SQL 2000
> >
> > Any insight or suggestions appreciated.
> > Don
>

Run a global variable dynamically

I have a SSIS pkg with several task. I need to run a global variable dynamically.

the global variable's value is basically a bat file with two arguments (\\.....\..bat \\......\.xls \\.....\...xls)

bat file arg1 arg2

This global variable gets set from its previous task at run time. I did put in this global variable as an argument in expression and for executable i am calling the cmd.exe file. But for some reason it does not work. the command prompt comes up wait for an action from user which is wrong. Please help

Thanks

Make sure that you have a full path to the batch file.

Also, make sure you are using the "/C" flag before the path to the batch file.

Command should look like:

cmd.exe /C \\server\mybatchfile.bat arg1 arg2......|||

Thanks Phil. That worked.