Solved

xp_cmdshell space

Posted on 2004-10-20
2
643 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.

733 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