Unable to access shared path from SQL Server Job

  • I have created a job which checks for excel files in a shared path(\\128.51.141.167\Import\File1.xls) and if all the files are existing in that path, then i shall continue to 2nd step of the job. Now if i check files in the system where sql server is, then its working fine. If i try check the files in the shared path, its always returning false saying that file does not exist.

  • Paste your code

  • The user under which your SQL server Agent is running might not have permissions on the shared folder. Just check the service credentials

    -Vikas Bindra

  • In the 1st step of the Job, i have written this code, with TYPE as Active X Script.

    CheckFiles()

    Function CheckFiles()

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    File1 = "\\136.51.141.167\temp\SCM.csv"

    File2 = "\\136.51.141.167\Test\HOST.csv"

    File3 = "C:\SCMExports\RELATIONSHIP.csv"

    File4 = "C:\SCMExports\SVC.csv"

    File5 = "C:\SCMExports\SCMServiceHostReln.csv"

    File6 = "C:\SCMExports\SCMServiceHostReln.csv"

    File7 = "C:\SCMExports\SCMServiceHostHwDetl.csv"

    If not objFSO.FileExists(File1) Then

    Set objFSO = Nothing

    CheckFiles = 1/0

    Exit Function

    End if

    If not objFSO.FileExists(File2) Then

    Set objFSO = Nothing

    CheckFiles = 1/0

    Exit Function

    End if

    If not objFSO.FileExists(File3) Then

    Set objFSO = Nothing

    CheckFiles = 1/0

    Exit Function

    End if

    If not objFSO.FileExists(File4) Then

    Set objFSO = Nothing

    CheckFiles = 1/0

    Exit Function

    End if

    If not objFSO.FileExists(File5) Then

    Set objFSO = Nothing

    CheckFiles = 1/0

    Exit Function

    End if

    If not objFSO.FileExists(File6) Then

    Set objFSO = Nothing

    CheckFiles = 1/0

    Exit Function

    End if

    If not objFSO.FileExists(File7) Then

    Set objFSO = Nothing

    CheckFiles = 1/0

    Exit Function

    End if

    Set objFSO = Nothing

    CheckFiles= 0

    End Function

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply