bcp does not recognize shared drive from query session

  • I try this command from a query session in sql server 2005 management studio. I tried it both from mgmt studio of my sql server 2005 client and the mgmt studio on the sql server itself.

    It cannot find the shared drive, in which I have full privileges. I have plans to add this bcp command as a step in a job.

    xp_cmdshell 'bcp [cptstest].[dbo].[cpu_history_max_by_hour] out "h:/cpu_history_max_by_hour.txt" -T -c -t ":"'

    Error = [Microsoft][ODBC SQL Server Driver]Unable to open BCP host data-file

    When I run from a cmd prompt on the sql server machine, it works:

    bcp [cptstest].[dbo].[cpu_history_max_by_hour] out "h:/cpu_history_max_by_hour" -T -c -t ":"

    Starting copy...

    5 rows copied.

    Network packet size (bytes): 4096

    Clock Time (ms.): total 313

    Why can't SQL Server see the shared drive the same as at the Windows level?

  • sgambale (2/1/2010)


    I try this command from a query session in sql server 2005 management studio. I tried it both from mgmt studio of my sql server 2005 client and the mgmt studio on the sql server itself.

    It cannot find the shared drive, in which I have full privileges. I have plans to add this bcp command as a step in a job.

    xp_cmdshell 'bcp [cptstest].[dbo].[cpu_history_max_by_hour] out "h:/cpu_history_max_by_hour.txt" -T -c -t ":"'

    Error = [Microsoft][ODBC SQL Server Driver]Unable to open BCP host data-file

    When I run from a cmd prompt on the sql server machine, it works:

    bcp [cptstest].[dbo].[cpu_history_max_by_hour] out "h:/cpu_history_max_by_hour" -T -c -t ":"

    Starting copy...

    5 rows copied.

    Network packet size (bytes): 4096

    Clock Time (ms.): total 313

    Why can't SQL Server see the shared drive the same as at the Windows level?

    Does your SQL Server serivce account have access to the shared folder? When you run from Cmd prompt, it uses windows credentials and when you run from SSMS, it uses SQL Server service account. Check the permissions of the shared folder.

  • I would attempt the full UNC path for this and see if that works for you.

    i.e.

    "\\servername\sharename\cpu_history_max_by_hour.txt"

  • I tried the full UNC path. Still did not work.

    I will try to get write privileges to that drive for the id that runs the sql server service and see if that resolves the issue.

  • I do not have the time to make the request to get admin rights to do this.

    Thanks for the help anyway!

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

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