473,471 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

xp_cmdshell always returns NULL

5 New Member
I am having a problem for which I have done numerous online searches but have not yet found an answer. I hope someone can help with it.

SQLServer 2008r2 on Microsoft Windows 2008r2

There is a stored procedure which runs nightly. I did not write the stored procedure and I do not have the right to change it.

Here is what the stored procedure does:
* dbcc of two databases
* uses xp_cmdshell to run a zipping program to zip a directory
* puts the contents of that directory into one of the databases
* Backs the database up

This stored procedure fails about half the time on ONE server. During my troubleshooting, I discovered that it is failing on the part where it runs the zipping program.

Here is what I've noticed:

* If I open a query window and type exec xp_cmdshell 'Dir c:\' and run it, the results will sometimes be a list of everything in the C:\ directory. When I get those results and then run the stored procedure, it works.

* Other times, when I run exec xp_cmdshell 'Dir c:\' the results are NULL. When that happens, if I run the stored procedure, it fails.

What I need to know is, what can cause xp_cmdshell to sometimes work and sometimes not. It will often change from working to not working while I am still in the same query window session in Management Studio.

1) I don't think it's permissions, or it would never work. It works and then it just suddenly stops working.

2) Please don't suggest I use some other method to zip the directory because, as I mentioned, this Stored Procedure runs successfully at a lot of our sites and I am required to support it but not to change it.

I have seen this issue appear in about 10 - 15 different sites. Most people either say "it's permissions" or "Don't use xp_cmdshell for that". Neither of those help me, nor did they help the people asking the questions. Only once did I see someone find his answer and it was anti-virus, but the antivirus software has been completely removed from this system and it's still happening.

I thank you for any help you can provide.
Dec 4 '12 #1
3 5002
NeoPa
32,556 Recognized Expert Moderator MVP
Interesting question Mike. One I wish I could help more with, but let's see what I can do.

I'm coming more from an OS perspective on this one. I do some SQL Server but very little of the standard stored procedures available. So, what can your information tell us? If this abberrant behaviour is occurring sometimes when run from a query window when run as a user (as opposed to being run from a service by anything scheduled) then I believe that points to an issue between SQL Server and the OS. These types of issues can get confusing when a service is used, particularly when network locations (or anything related to security tokens) are involved. The root of the C: drive can have restricted security, but it's rare at that level for it to cause issues, and that tends to be an issue with scheduled tasks run under credentials other than the current user's (even sometimes when it interacts with the current user). I think it safe to say the problem won't be found looking in those areas

That hasn't really helped much looking at it, but it at least identifies a number of ares that needn't be looked at. One of these is the existing setup, as far as I can see. The differences between working and not working appear to be way outside the area of redoing the logic.

PS. Don't think too badly of people suggesting alternative approaches. It's not so great for searching through existing threads, but it can be very helpful for the OP in their time of need. Never fear, I've noted your preference on this occasion and won't go there on this one ;-)
Dec 5 '12 #2
MikeMacairan
5 New Member
Thanks for the reply, NeoPa, it's a good start.

Please understand that I was not thinking badly about people who post alternatives. I know sometimes an alternative solution is best. I was just saying that I am not allowed to change the stored procedure, so an alternative wouldn't work for ME. Also, I know this stored procedure works at dozens of other sites, so I'm really trying to find what causes it to stop working here, in order to make this one work like all the other sites.
Dec 5 '12 #3
NeoPa
32,556 Recognized Expert Moderator MVP
I do understand Mike. Really. It's a perfectly valid point to make.

I've gone as far as I can for now, but I'll wait, as you do, for any further insights from anyone. Something may trigger further ideas when posted.
Dec 5 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rene van Hoek | last post by:
Hi, I am using Xalan 1.8.0 and Xerces 2.6.0 in C++. I have an XML document which I first transform into an other XML document using an XSL styelsheet. Then I want to parse with XPathEvaluator...
1
by: Sergio Geralnik | last post by:
I am trying to use this method to get a MethodInfo object but the method always returns a null. See my sample code below: this.button1 = new System.Windows.Forms.Button(); this.button1.Click +=...
3
by: Zoury | last post by:
Good day! :O) I have the following code : //*** using System; using System.Windows.Forms; <snip>
8
by: Brian | last post by:
This is causing me to not be able to create a relation in my dataset. Here's my code: dc1 = ds.Tables .Columns ; dc2 = ds.Tables .Columns ; dr1 = new System.Data.DataRelation...
0
by: Ben Fidge | last post by:
Hi When my ASP.NET application traps an exception, it's details and the call stack are written to a log, but for some reason, StackFrame.GetFileName() always returns null. This is when running...
10
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
1
by: H | last post by:
Just trying to create a basic xmlhttpobject. However, the following always returns null xmlhttpobj = New ActiveXObject("Microsoft.XMLHTTP") (it is Microsoft. and not Msxml2. I've already...
6
by: prpleprncs | last post by:
I have a dropdownlist that is selected on page_load. the values of the dropdown comes from the database using a datasource at design time. the value that needs to be selected comes from the...
2
by: r3ap3r | last post by:
I am using the following recursive function for an assigment string GetString(char numbers, int curNum){ string returnString = ""; int temp; if (numbers != '\0'){ for (int i = 0; i <=2;...
3
pragathik
by: pragathik | last post by:
hi, i have a problem with document.body.offsetTop and document.body.offsetLeft always returns null in my code in IE6. how can I get the values???? please suggest
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.