Solved

xp_cmdshell space

Posted on 2004-10-20
2
639 Views
Last Modified: 2006-11-17
I'm trying to something like the following:

Declare @myCommand varchar(255)
Set @myCommand = 'copy F:\Folder\SubFolder\file.txt  F:\Folder\SubFolder\my archive\file.txt'
EXEC xp_cmdshell @myCommand

I get an error "The syntax of the command is incorrect."

I believe this is due to the space in "my archive".  What am i doing wrong?  If it is the space, how do handle the syntax?
0
Comment
Question by:wordtool
2 Comments
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 20 total points
ID: 12365015
try

Set @myCommand = 'copy "F:\Folder\SubFolder\file.txt"  "F:\Folder\SubFolder\my archive\file.txt"'

other than that, I don't see any problems...
0
 

Author Comment

by:wordtool
ID: 12365064
Yes, the quotes work, thank you.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question