I am having a problem with one of my servers where I cannot execute xp_cmdshell under certain conditions. The full problem can be found here problem running xp_cmdshell when Application Name set in connection string

I want to see if dropping and recreating it will fix it (on a test server first). I'm grabbing at straws here.

1 Answer 1


No, you can't drop and re-create xp_cmdshell. It's not even its own procedure, but part of a library in xpstar.dll (or at least it was at one point). And I am extremely skeptical that, even if you could re-create this procedure, that would fix the problem you're having.

Maybe instead of banging your head against this problem with xp_cmdshell, you should just bite the bullet and implement the functionality you need in CLR. Or perform the tasks you need outside of SQL Server altogether.

  • I use xp_cmdshell to execute bcp for bulk imports and exports of data. Are SQL CLR objects capable of doing the same bulk table operations speedy fashion like bcp? Apr 23, 2013 at 1:07
  • 1
    Sure, and so is a background process. Why must the BCP ultimately be initiated by T-SQL? What event occurs that tells T-SQL to call xp_cmdshell to call BCP? Couldn't this just log an entry in a queue table, and then a background process, written in C# or PowerShell or VBScript or what have you, that wakes up every n seconds or minutes, and checks for any new tasks in the queue table? Apr 23, 2013 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.