SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Run EXE from Stored Procedure


Run EXE from Stored Procedure

Author
Message
getshir
getshir
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 1
Hi,

Is any way to run any EXE file from SQL Server 2000 >> Stored Proc

Thanks
Jason Crider
Jason Crider
Mr or Mrs. 500
Mr or Mrs. 500 (587 reputation)Mr or Mrs. 500 (587 reputation)Mr or Mrs. 500 (587 reputation)Mr or Mrs. 500 (587 reputation)Mr or Mrs. 500 (587 reputation)Mr or Mrs. 500 (587 reputation)Mr or Mrs. 500 (587 reputation)Mr or Mrs. 500 (587 reputation)

Group: General Forum Members
Points: 587 Visits: 2232
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
Bhuvnesh
Bhuvnesh
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5226 Visits: 4076
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 Smile

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
RBarryYoung
RBarryYoung
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14692 Visits: 9518
getshir (9/22/2008)
Is any way to run any EXE file from SQL Server 2000 >> Stored Proc
XP_CMDSHELL is all you need.

-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
giri_engg2001
giri_engg2001
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 15
master..xp_cmshell

executed above command ..


query result shows me..query executed succesfully..but file is not copied
Glen Sidelnikov
Glen Sidelnikov
Right there with Babe
Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)

Group: General Forum Members
Points: 717 Visits: 804
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.
RBarryYoung
RBarryYoung
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14692 Visits: 9518
You do realize that this executes on the Server and not on the Client, right?

-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Glen Sidelnikov
Glen Sidelnikov
Right there with Babe
Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)Right there with Babe (717 reputation)

Group: General Forum Members
Points: 717 Visits: 804
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.
parth83.rawal
parth83.rawal
SSC-Enthusiastic
SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)

Group: General Forum Members
Points: 138 Visits: 160
Hi,
I have an EXE file which i would like to run, what i am doing is running following script but in void.... Sad

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
RBarryYoung
RBarryYoung
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14692 Visits: 9518
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.... Sad

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.

-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
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