Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    139

    Unanswered: execute batch file as sql job

    I'm trying schedule a batch file to run as a job from sql server agent. The batch file copies files from one server directory to a directory on another server. The batch file works properly when executed directly. The job is being executed under the sql service account login. I've given the service account access to both the source and destination directories.

    When I try to run the job it fails with an "Access is denied" error on both the source and destination directories (as read from job history).

    Any ideas?
    Thanks,
    Bill

  2. #2
    Join Date
    Aug 2003
    Location
    austin,tx
    Posts
    104
    I'd try to log into the server under the sql service acct and try to execute the batch file directly that way. It may give you some more clues.

    Beyond that, maybe place some output in the SP to verify the user it is running under when executed from the job.
    SELECT SYSTEM_USER

  3. #3
    Join Date
    Mar 2004
    Posts
    139
    I can log in and run the job under the service account. I imagine there must be some kind of proxy account or something that it's run under. Like aspuser in .net.
    Thanks,
    Bill

  4. #4
    Join Date
    Aug 2003
    Location
    austin,tx
    Posts
    104
    Create a simple table with a varchar column in it. From the stored procedure, insert SYSTEM_USER into the table. After the job executes, check the table and see what the user name was.
    Something like:
    CREATE tmpTable (c1 varchar(30) )
    INSERT INTO tmpTable SELECT SYSTEM_USER

  5. #5
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    maske sure the sql service is running under a domain account and that account has permissions over both directories.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •