Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xp_cmdshell - create txt file in remote computer

Status
Not open for further replies.

snoopyyu

Programmer
Jan 9, 2004
12
US
I am having problem creating/copying txt file in a remote computer using the xp_cmdshell cmd from Query Analyzer:

Got the following errror message when execute:

exec master..xp_cmdshell 'copy D:\result.txt \\<myservername>\<myfoldername>\result.txt'

(where I have permission to write on \\<myservername>\<myfoldername>\result.txt)


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

However, when copying it locally, like the following:
exec master..xp_cmdshell 'copy D:\result.txt D:\abc\result.txt'
This is working fine without problem.

Any ideas? Thanks in advace.

 
Sorry, the command corresponding to the error message should be:

exec master..xp_cmdshell 'bcp &quot;SELECT * FROM pubs..authors&quot; queryout \\<myservername>\<myfoldername>\authors.txt -U sa -P -c'
 
Shouldn't you have something between the dots? A user

master..xp_cmdshell

My statements always use

EXEC master.dbo.xp_cmdshell
 
No, this is not necessary. master..xp_cmdshell is working.
The problem was resolved. It was the windows startup service account issue. That account must be a domain account with the neccessary permission.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top