Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Run EXE from Stored Procedure Expand / Collapse
Author
Message
Posted Monday, September 22, 2008 4:26 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, September 22, 2008 4:23 PM
Points: 1, Visits: 1
Hi,

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

Thanks
Post #573919
Posted Monday, September 22, 2008 5:40 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, September 3, 2014 6:35 AM
Points: 282, Visits: 2,211
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
Post #573938
Posted Tuesday, September 23, 2008 4:55 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 12:26 AM
Points: 2,840, Visits: 3,963
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
Post #574201
Posted Tuesday, September 23, 2008 7:52 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,902, Visits: 9,480
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."
Post #574857
Posted Wednesday, September 24, 2008 9:34 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, September 29, 2008 4:42 AM
Points: 6, Visits: 15
master..xp_cmshell

executed above command ..


query result shows me..query executed succesfully..but file is not copied

Post #575324
Posted Wednesday, September 24, 2008 9:42 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, August 5, 2013 12:19 PM
Points: 371, Visits: 797
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.
Post #575331
Posted Wednesday, September 24, 2008 11:02 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,902, Visits: 9,480
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."
Post #575418
Posted Wednesday, September 24, 2008 11:18 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, August 5, 2013 12:19 PM
Points: 371, Visits: 797
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.
Post #575430
Posted Friday, October 2, 2009 10:18 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, March 6, 2013 11:48 PM
Points: 66, 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....

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
Post #797063
Posted Friday, October 2, 2009 10:28 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,902, Visits: 9,480
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.


-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #797070
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse