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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 BCP to remote server

Author  Topic 

fralo
Posting Yak Master

161 Posts

Posted - 2011-01-04 : 15:53:13
I need to output a file from one server to another. How might I do this with BCP?

Here's something which generates it locally.

select @sqloutput = 'bcp test.dbo.test_con out c:\bcp\concentra.txt -c -t "|" -T'

Thanks for your help.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-04 : 16:03:59
You can place the file on a remote server if you use the UNC path. Or you can simply bcp the data in to the remote server directly from that local C drive.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

fralo
Posting Yak Master

161 Posts

Posted - 2011-01-04 : 16:13:08
Thanks Tara, but I'm completely new to this. Would it look something like this?

select @sqloutput = 'bcp test.dbo.test_con out \\servername\\c$\ftp\concentra.txt -c -t "|" -T'

Thanks.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-04 : 16:13:45
\\servername\c$\ftp\concentra.txt

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

fralo
Posting Yak Master

161 Posts

Posted - 2011-01-04 : 16:33:49
My path actually contains the 'Program Files' although I didn't post it. It's not working perhaps because it contains blank spaces?

select @sqloutput = 'bcp test.dbo.test_con out \\servername\c$\Program Files\ftp\concentra.txt -c -t "|" -T -S'

Would I need to set a variable and then have something like this?

select @sqloutput = 'bcp test.dbo.test_con out @unc\concentra.txt -c -t "|" -T -S'



Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-04 : 16:37:12
You'll need to add double quotes around your path. I'd highly recommend that you use an alternate path that doesn't have space in it. It makes it so much easier! Or, create a share to the FTP folder, so you can skip c$ and program files.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

fralo
Posting Yak Master

161 Posts

Posted - 2011-01-04 : 17:19:33
I thought double quotes but it doesn't.

select @sqloutput = 'bcp test.dbo.test_con out "\\servername\c$\Program Files\ftp\concentra.txt" -c -t "|" -T -S'
Go to Top of Page
   

- Advertisement -