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 2000 Forums
 SQL Server Development (2000)
 BCP Bulk Copy Program

Author  Topic 

MikeB
Constraint Violating Yak Guru

387 Posts

Posted - 2009-02-03 : 13:23:03
Can I use BPC (Bulk Copy Program) to copy the results of a query to a text file on a different server? If so, how can this be done?

My current command in the stored proc is as follows:

SELECT @sql = 'bcp ##Accounts out ' + RTRIM(@cFilePath) + RTRIM(@cProject) + '.exp -c -t, -T -S ' + @@servername
SELECT @sql AS Statement
exec master..xp_cmdshell @sql


If I set the @cFilePath to a different server folder path, the file does not get written out.

If the folder is on the same server as SQL I don't have a problem. I thought originally it was a Access Issue, but the administrator login is used so it cannot be an security issue.

Any suggestions?

Mike B

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-03 : 13:27:36
i think you need to use UNC path name like //Server/....
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-03 : 13:30:14
quote:
Originally posted by visakh16

i think you need to use UNC path name like //Server/....



It should be \\Servername\...
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-03 : 13:39:55
What error are you getting returned from the xp_cmdshell call?

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

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-03 : 13:40:27
Also show us what gets passed to @sql by running PRINT @sql.

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

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-03 : 13:58:01
quote:
Originally posted by sodeep

quote:
Originally posted by visakh16

i think you need to use UNC path name like //Server/....



It should be \\Servername\...


ah sorry i had put the wrong slash
seems like its time for me to sleep ...zzz
Go to Top of Page
   

- Advertisement -