Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


xp_cmdshell in stored procedure not the same result as cmd prompt


xp_cmdshell in stored procedure not the same result as cmd prompt

Author
Message
dirk.dromgoole
dirk.dromgoole
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 26
I have a stored procedure that uses xp_cmdshell to execute an executable. I made code changes to the executable and compiled a new build. The stored procedure that uses xp_cmdshell to execute is not recognizing the code changes but when I run the same command from cmd prompt it works fine. Any ideas?
Eirikur Eiriksson
Eirikur Eiriksson
SSCertifiable
SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)

Group: General Forum Members
Points: 6697 Visits: 17691
dirk.dromgoole (5/20/2014)
I have a stored procedure that uses xp_cmdshell to execute an executable. I made code changes to the executable and compiled a new build. The stored procedure that uses xp_cmdshell to execute is not recognizing the code changes but when I run the same command from cmd prompt it works fine. Any ideas?


First thought would be more than one instance of the executable on the system.
Cool
Ed Wagner
Ed Wagner
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10236 Visits: 9560
I'm thinking the same thing. When you shell out, are you giving it the full path and filename to the executable? If not, then you're probably executing the wrong copy of it, so you're not getting the results from the new one.


Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Orlando Colamatteo
Orlando Colamatteo
SSCrazy Eights
SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)

Group: General Forum Members
Points: 8237 Visits: 14368
Sounds like a reason to move away from xp_cmdshell. What is the executable doing and can it be hosted on a machine other than a machine hosting SQL Server and be executed via a remote shell?

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Igor Micev
Igor Micev
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4166 Visits: 4847
Hi
When you make changes to the executable you can recompile the SP.
You could also create the SP with recompile option, so it removes and creates new plans for next executions.


Igor Micev,
‌SQL Server developer at Seavus
www.seavus.com
dirk.dromgoole
dirk.dromgoole
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 26
The issue was that a copy of the program that was being executed was somehow locked into cache on the server. After the program was unlocked it picked up the revised program.
Eirikur Eiriksson
Eirikur Eiriksson
SSCertifiable
SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)

Group: General Forum Members
Points: 6697 Visits: 17691
dirk.dromgoole (6/17/2014)
The issue was that a copy of the program that was being executed was somehow locked into cache on the server. After the program was unlocked it picked up the revised program.

Very curious here, could you share some details on this?
Cool
Go


Permissions

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

































































































































































SQLServerCentral


Search