September 22, 2008 at 4:26 pm
Hi,
Is any way to run any EXE file from SQL Server 2000 >> Stored Proc
Thanks
September 22, 2008 at 5:40 pm
Might want to put this in a SQL Server 2000 forum, but here's a head start:
http://www.codeproject.com/KB/database/xyprocedure.aspx
MCITP, Database Administrator
A hodgepodge of Information Technology and Life
LinkedIn Profile
My Twitter
September 23, 2008 at 4:55 am
include following script in your Stored Proc
declare @sqlcmd varchar(200)
SET @SQLCmd = 'copy c:\dba\sampl.xls c:\dba\sampl_2.xls'
EXEC master..xp_cmdshell @SQLCmd , no_output 🙂
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
September 23, 2008 at 7:52 pm
getshir (9/22/2008)
Is any way to run any EXE file from SQL Server 2000 >> Stored Proc
XP_CMDSHELL is all you need.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
September 24, 2008 at 9:34 am
master..xp_cmshell
executed above command ..
query result shows me..query executed succesfully..but file is not copied
September 24, 2008 at 9:42 am
You should verify that the security context under which you are running xp_cmdshell has rights on the file system where you are trying to copu a file.
September 24, 2008 at 11:02 am
You do realize that this executes on the Server and not on the Client, right?
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
September 24, 2008 at 11:18 am
Excerpt from http://www.databasejournal.com/features/mssql/article.php/3372131
"Now not just anyone can run this extended stored procedure. If you want to execute this extended stored procedure, you will either need to be a member of the sysadmin role, or have the xp_sqlagent_proxy_account set up on your SQL Server. If a login executing this extended stored procedure is a member of the sysadmin role then the submitted command will run under the security context associated with the SQL Server Service account in which it runs. If the login executing this procedure is not a member of the sysadmin role, then the command uses the xp_sqlagent_proxy_account login security context for determining whether operating system commands can and cannot be run. If there is no xp_sqlagent_proxy_account then using this procedure will fail for all users not in the sysadmin role. "
Assuming that we are in the case when xp_cmdshell is running under security context of the SQL server service account, you also has to make sure that this account INDEED have security rights on the file system where you are trying to copy a file.
October 2, 2009 at 10:18 am
Hi,
I have an EXE file which i would like to run, what i am doing is running following script but in void.... 🙁
declare @sqlcmd varchar(200)
SET @sqlcmd = 'WinWSSList.exe'
EXEC master..xp_cmdshell @sqlcmd
Now what it gives me as output is :
'WinWSSList.exe' is not recognized as an internal or external command,
operable program or batch file.
NULL
What to do ??
Thanks
Parth
October 2, 2009 at 10:28 am
parth83.rawal (10/2/2009)
Hi,I have an EXE file which i would like to run, what i am doing is running following script but in void.... 🙁
declare @sqlcmd varchar(200)
SET @sqlcmd = 'WinWSSList.exe'
EXEC master..xp_cmdshell @sqlcmd
Now what it gives me as output is :
'WinWSSList.exe' is not recognized as an internal or external command,
operable program or batch file.
NULL
What to do ??
Thanks
Parth
It's telling you that it cannot find this exe file. Be sure to include the path to this EXE. And remember that this is executed on the Server, and not on your Client.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
October 2, 2009 at 11:21 am
Hi,
First of all thanks for the prompt reply.
My EXE is in C Drive only, and it is running fine, if i run from the command prompt.
and my server and exe both are on server only. some how it is not running.
Thanks
Parth
October 2, 2009 at 2:18 pm
try using full path of the executable. So instead of
SET @sqlcmd = 'WinWSSList.exe'
use
SET @sqlcmd = 'C:\WinWSSList.exe'
@sqlcmd session may open a command prompt somewhere in the binn folder of the SQL where your executable does not exist.
October 2, 2009 at 8:50 pm
parth83.rawal (10/2/2009)
My EXE is in C Drive only, and it is running fine, if i run from the command prompt. and my server and exe both are on server only. some how it is not running.
What makes you think that the xp_cmdshell process's starting directory is "C:\"? It probably isn't, which is why should try what I suggested and specify the full path.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
January 26, 2010 at 11:13 am
Do you till have this problem?
'WinWSSList.exe' is not recognized as an internal or external command,
operable program or batch file.
NULL
By this statement, I understand the 'WinWSSList.exe' cant be executed from Command Prompt.
Try executing this from command prompt.
Regards,
Gautham Akula
January 26, 2010 at 10:47 pm
indeed it is working from command prompt but not working from SQL, 🙁
and then i changed my approach.....but still i would like to know the answer for that. 🙂
Thanks
Parth
Viewing 15 posts - 1 through 15 (of 15 total)
You must be logged in to reply to this topic. Login to reply