Microsoft KB Archive/152134

= PRB: XP_CMDSHELL Does Not Work with XCOPY =

Article ID: 152134

Article Last Modified on 11/14/2003

-

APPLIES TO


 * Microsoft SQL Server 6.0 Standard Edition
 * Microsoft SQL Server 6.5 Standard Edition
 * Microsoft SQL Server 7.0 Standard Edition

-



This article was previously published under Q152134





SYMPTOMS
XP_CMDSHELL does not work with XCOPY. When tried, the XP_CMDSHELL always returns "0 rows affected," and files and directories are not copied. The same XCOPY command works fine from the command prompt.

NOTE: This problem does not occur with Microsoft SQL Server 2000.



CAUSE
Certain commands such as XCOPY sometimes expect input from the user. Because of this, they must be assigned an input handle. Since we do not create the process with an input handle assigned, it fails.



WORKAROUND
To work around this problem you can use the COPY command instead. Or, you can also pipe the output to a NUL console. For example: xp_cmdshell 'fc c:\test1.txt c:\test.txt c:\output.txt'

Additional query words: extended stored procedure

Keywords: KB152134

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.