Solved

xp_cmdshell space

Posted on 2004-10-20
2
637 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now