Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
+1 wish I could +10 this answer. – Thomas Stringer Apr 23 '13 at 0:21
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? – John Petrak Apr 23 '13 at 1:07
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? – Aaron Bertrand Apr 23 '13 at 1:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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