Re: Run Batch Files with SQL Server Agent

From: Guru (gss20_at_hotmail.com)
Date: 02/24/04


Date: Tue, 24 Feb 2004 10:26:58 -0800

Make a little change to the batch file and add folloiwng
line at different places:

@echo In the batch file at line <#>

when you run the batch file in QA it should display these
messages in results window.

In Enterprise Manager, if you open properties of SQL
Server Agent, click on Job System, you will see option to
specify proxy account, use a local admin for it, and then
restart sql services.

hope this helps.

>-----Original Message-----
>Hi,
>
>I forgot that SQL Server 2000 does not have this proxy
>account on the local server. I did find a domain
>account 'SQLServerAcctCmdExec' and I added this to the
>local administrators account and it still did not work.
>
>DeeJay
>>-----Original Message-----
>>I tested running the job with me as the owner and I am a
>>local administrator on this server. I have also tried
>>using 'sa' and the service startup and nothing is
working.
>>
>>I have tried running the xp_cmdshell procedure in QA and
>>it also does not work...I just get the output as 'NULL'.
>>
>>I wonder if it is ONLY using the proxy account. That
>>account may not have the required permissions.
>>
>>I will check that.
>>
>>DeeJay
>>>-----Original Message-----
>>>For real time error info, try to execute xp_cmdshell
>from
>>>query analyzer.
>>>
>>>I wonder if it is a permission issue, if the job owner
>is
>>>a sysadmin then then sql server will use service
startup
>>>account to execute xp_cmdshell, otherwise it will use a
>>>proxy account. Does sql startup account has permissions
>>to
>>>delete those files ?
>>>
>>>hth.
>>>
>>>>-----Original Message-----
>>>>That's the weird part...I do not get any errors.
>>Actually
>>>>according to the agent the job completes successfully,
>>>but
>>>>the files are not deleted.
>>>>
>>>>I tried your suggestion and it did not work. But this
>>>time
>>>>I do get an error:
>>>>
>>>>The process could not be created for step 1 of job
>>>>0xC38683087ECAA14AB6614A1A74F27555 (reason: Overlapped
>>>I/O
>>>>operation is in progress). The step failed.
>>>>
>>>>This is really confusing. I do not want to run the
>>>>manually every other day.
>>>>
>>>>Thanks,
>>>>DeeJay
>>>>
>>>>>-----Original Message-----
>>>>>Do you get any error message, what happens when you
>try
>>>>to
>>>>>run the job ?
>>>>>
>>>>>How long the batch file takes to run ? We had an
issue
>>>>>where sql agent timed out if the batch file took more
>>>>than
>>>>>30 minutes to run. It happened only once and we ran
>the
>>>>>file manually from command prompt. You can also try
to
>>>>run
>>>>>it as a tsql command using Exec
>>>>>master.dbo.xp_cmdshell 'e:\sqlbackups\delete.bat'
>>>>>
>>>>>hth.
>>>>>
>>>>>>-----Original Message-----
>>>>>>Hi
>>>>>>
>>>>>>Thanks, but that's exactly how I have been trying to
>>>run
>>>>>>it, but it does not work.
>>>>>>
>>>>>>I am running the job with an administrative account
>>>that
>>>>>>has the required permissions.
>>>>>>
>>>>>>I have tested the script by running is manually on
>the
>>>>>>server and it works fine.
>>>>>>
>>>>>>I wonder what gives.
>>>>>>
>>>>>>DeeJay
>>>>>>>-----Original Message-----
>>>>>>>Hi,
>>>>>>>
>>>>>>>In SQL Agent Jobs -- Step option, after
>>>>>>selecting 'Operating System Command
>>>>>>>(CmdExec)' , In the command window you can type
>>>>>>>
>>>>>>>e:\sqlbackups\delete.bat
>>>>>>>
>>>>>>>(This will call the batch file delete.bat based on
>>the
>>>>>>schedule interval)
>>>>>>>
>>>>>>>Thanks
>>>>>>>Hari
>>>>>>>MCDBA
>>>>>>>
>>>>>>>"DeeJay Puar" <deejaypuar@yahoo.com> wrote in
message
>>>>>>>news:14f3201c3fa33$599d4120$a001280a@phx.gbl...
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I am trying to run a batch file using the SQL
>>Server
>>>>>>Agent
>>>>>>>> (I have scheduled a job). I have chosen the step
>>>type
>>>>>to
>>>>>>>> be 'Operating System Command (CmdExec)'. But I am
>>>not
>>>>>>sure
>>>>>>>> how to code the actual command.
>>>>>>>>
>>>>>>>> The batch file is located at:
>>>>e:\sqlbackups\delete.bat.
>>>>>>>>
>>>>>>>> How do specify the Agent to call this batch file?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> DeeJay
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>.
>>>>>>>
>>>>>>.
>>>>>>
>>>>>.
>>>>>
>>>>.
>>>>
>>>.
>>>
>>.
>>
>.
>



Relevant Pages

  • RE: Problem with SidWalk and ShowAccs asking for admin privelege
    ... the server - then it worked!! ... Before I used my personal account to login to ... > 2.Login using a DOMAIN user which is member of the local Administrators ... > I suggest double check if the account is in the local administrators group ...
    (microsoft.public.windows.file_system)
  • Re: Administrator account does not have rights
    ... >about an account that is a domain administrator, ... >check membership of the local administrators group anyhow ... >auditing of logon events and account management enabled ... I have a 2000 server and the administrator ...
    (microsoft.public.win2000.security)
  • Question on Account Usage
    ... What account does SMS use when it runs a program, ... such as a batch file, that calls to another server to run a exe. ...
    (microsoft.public.sms.setup)
  • Re: Fix for: Server Application Unavailable Error after Applying Security Update for IE
    ... > We have identified an issue with the recent MS03-32 Security Update for> Internet Explorer security patch and ASP.NET V1.0 running on Windows XP. ... all requests to ASP.NET applications running on the local IIS 5.1 web> server result in an error message saying "Server Application Unavailable". ... In the meantime,> you can execute the following batch file as a workaround for the issue. ... > Stops the IIS and ASP.NET state services> Deletes and recreates the ASPNET account with a known temporary password> Uses the Windows runas command to launch an executable that creates an ASPNET ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: A required privilege is not held by the client
    ... >> files is being run is a Domain Admin account. ... >> file has only the exit command. ... I can log in locally and run the batch file. ...
    (microsoft.public.win2000.general)