Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 bcp out to a network shared drive

Author  Topic 

padhma.p
Yak Posting Veteran

91 Posts

Posted - 2009-09-10 : 14:47:18
Hi,

I have a SP on a SQL box, which currently outputs the result into a file and saves it on the local drive. If i want to save it on a shared network drive, can i do it and how?

I am currently logged in with admin account into the sql box, i want to save the output on a drive on a different machine,which i have mapped as a network drive in the SQL box.

Please advise.
Padhma

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-10 : 15:13:05
I would try and see what happens...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

padhma.p
Yak Posting Veteran

91 Posts

Posted - 2009-09-10 : 15:22:01
Hi webfred,

I tried.
This is my code:
'bcp out "\\servername\F:\Data\test.txt" -c -t, -T'


This is the error:
SQLState = HY000, NativeError = 0
Error = [Microsoft][SQL Native Client]Unable to open BCP host data-file


Padhma
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-10 : 15:36:00
If you have mapped to drive f: there is no need (no it is a mistake) to give the servername.
If drive f: on local box is mapped to \\servername\data\ then just use F:



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

padhma.p
Yak Posting Veteran

91 Posts

Posted - 2009-09-10 : 15:47:09
I have tried that as well. Same error.

here F:\ corresponds to the local drive on the remote server "servername" and Data is a folder under the F:
On my server SQL , i have Z:\ which opens up the shared drive at \\servername\F:\

I have tried using
'bcp out "Z:\Data\test.txt" -c -t, -T'

same error.

Padhma
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-10 : 16:00:32
The shared folder or drive must have a name - not F:


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

padhma.p
Yak Posting Veteran

91 Posts

Posted - 2009-09-10 : 16:08:33
Yes,there is, I have tried that.

\\servername\sharename\foldername\test.txt

have also tried z:\foldername\test.txt

Mapped drive z:\ --> \\servername\sharename
Same error.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-10 : 16:14:36
Sorry then I don't know but maybe there is no right configured to point to a network drive.

Sorry padhma

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-09-10 : 17:38:08
quote:

I tried.
This is my code:
'bcp out "\\servername\F:\Data\test.txt" -c -t, -T'



You are missing the table name in the BCP statement.
Try this:
bcp "master.dbo.sysdatabases" out "\\servername\Data\test.txt" -c -t, -T

Do you still get an error?

The mapped drive option is dependent on the user account, and seldom works with service accounts (which don't have the same drive mappings)
Go to Top of Page

padhma.p
Yak Posting Veteran

91 Posts

Posted - 2009-09-11 : 08:56:35
Yes. I still get the same error.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-11 : 09:46:09
bcp "master.dbo.sysdatabases" out "\\servername\F$\Data\test.txt" -c -t, -T

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

padhma.p
Yak Posting Veteran

91 Posts

Posted - 2009-09-11 : 10:06:32
Same error.
Go to Top of Page

padhma.p
Yak Posting Veteran

91 Posts

Posted - 2009-09-11 : 10:21:16
Madhi and webfred,

I am not sure why I keep getting the same error though I have full access on both the machines. Alternatively, I am copying to another machine via:
xcopy command using a bacth file.

Thank you.
Go to Top of Page
   

- Advertisement -