BCP from a mapped Drive

  • Dear Members

    I a having a requirement where I need to import data from a text file to my server.This text file is located on a machine in LAN, the drive is mapped.

    I am using BCP to do the job, but it fails, sying "Access is denied"

    My SQL server service is running under an account which has all administrative rights.But on machine  I logged in as a different user.

    Please let me know how to do BCP over a network from mapped drives.

     

    Regards and Thanks

    Vishal

  • One option:

    Map a driver with right credential so you can read from the file.

    Then bcp.

  • I have mapped the drive from the command prompt I am able to copy files from mapped drive , but when I run the same command using xp_cmdshell then it says unknown username or wrong password.

    Please guide

     

  • Are you mapping supplying a username & password?

    Does your SQL Server / SQL Server Agent account have permissions to the files on the network server? to the share?

    Are you running an Active Directory domain on Windows 2003 servers? or what network configuration ? Does your server have authentication delegation enabled?

     


    Julian Kuiters
    juliankuiters.id.au

  • I suggest that instead of using mapped drives, use the uncname (ex. \\servername\foldername) and verify that the sql server agent account has permissions to the foldername.  As for the permission problem, you need to grant execute to public for the stored procedure master..xp_cmdshell

     

  • UNC file naming is the way to go from xp_cmdshell. Just make sure that the SQL Server service account has access if you are running from QA. If it's a scheduled task then make sure that the SQL Agent service account has access.

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • Here I am presenting some details.

    SQl Server Name :  Commexchange

    DOmain             : IndexExchange

    Login UserId       :  Admin

    SQl Server Service is running under username : Admin

    SQl Agent service is running under usernmae : Admin

    If from Commexchange I try to connect one network machine(Asian50) , I am able to connect.

    I go to command prompt and issue DIR command to get the directory structure of Asian50 then I am  able to get it, but when I issue same command from QA using xp_cmdshell it gives me following error

    Logon failure: unknown user name or bad password.

    I am issuing the following command from QA

    exec master..xp_cmdshell  "dir \\asian50\D: /p"

    I am not able to figure out the cause of the error message I am getting

    Please help me out.......................

  • 1) What type of user is 'Admin' ? Domain user, domain admin ???

    2) Is login 'Admin' a local admin on 'asian50' ?

     

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • Admin is just a userid created on Commexchange.

    It has all administrator rights on the db server.

     

    On asian50 it is not local admin.

  • Try giving Admin read/write access to the directory on asian50 (least privilege rule).

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

Viewing 10 posts - 1 through 9 (of 9 total)

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