SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

xp_cmdshell failing in SQL Server 2000 SP4

xp_cmdshell failing in SQL Server 2000 SP4

lee.norman 47652
lee.norman 47652
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 36
This problem is occurring on a server that just recently fell to me. The OS is Server2003 SP2. There are nightly backups going to a local drive. Sometime later in the day, Veritas NetBackup copies them off to tape. There are maintenance plans in place that delete the old backups. The problem is that things have grown to the point that there is not enough room for two backups out there. I've tried messing with maintenance plans trying to get the old backups deleted before generating the new ones, but I haven't had any luck. Since the old backups are still there when the new ones run, the backups fail due to inadequate disk space. I don't know how long this has been going on - it's longer than the job history.

I have tried to get around this by deleting the old backups before the maintenance plans kick off. To do this, I created a job to run 5 minutes before the maintenance plans start. That job contains a single step consisting of the following:

cmd /C DEL /S /Q /A-A "D:\SQLBackups\*.bak"

When I execute the job, it fails. The only message I can find anywhere is in the job history. There is nothing in the SQL Server Logs. There is nothing in the Event Viewer. There is nothing I can find anywhere. This is what appears in the job history:

The job failed. The Job was invoked by User <username>. The last step to run was step 1 (Delete Old Backups).

I have have pasted everything from the DEL on into a command prompt and it works fine. I have pasted the entire string into Start-->run and it works fine. But the job routinely fails.

This job is owned by the service account. It is the account that SQL Server and the agent are running under. It's a local admin on the box. It has the System Administrators role checked. It has db_owner on every database on the box. When I look at the properties on xp_cmdshell and click permissions, I see this account with EXEC checked. If this is a permissions issue, I sure can't find where it's being denied.

As nearly as I can tell, this account has God-like permissions on both the server and with SQL Server. I know the command string is good because I have run it using two other methods. Yet the job always fails and gives me nothing to go on but that nebulous "The job failed."

While my immediate question is how to make this work or where else to look for some actual error message or number, I'm also open to any other ideas for how to accomplish this task.


You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum