Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 XP_CMDSHELL

Author  Topic 

oakridge
Starting Member

1 Post

Posted - 2010-03-28 : 16:32:03
I am running the following code as a job under SQL 2008 as the first part of a program.

declare @strFile nvarchar(300)
set @strfile='copy D:\PLC\potran.txt D:\PLC\Invoicearchive\potran'+
replace(replace(replace(convert(nvarchar,getdate(),120),' ',''),':',''),'-','')+'.txt'
select @strfile
EXEC master..xp_cmdshell @strfile

This has been running fine until a reboot of the server. Now it fails at this point and also when I run it under the query window.

I get the following error

Msg 15121, Level 16, State 21, Procedure xp_cmdshell, Line 1
An error occurred during the execution of xp_cmdshell. A call to 'CreateProcess' failed with error code: '2'.

Why does the SP no longer work?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-03-29 : 13:48:29
Do any commands work through xp_cmdshell? Try this to see: EXEC master..xp_cmdshell 'dir C:\'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -