Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Development
»
Run EXE from Stored Procedure
16 posts, Page 1 of 2
1
2
»»
Run EXE from Stored Procedure
Rate Topic
Display Mode
Topic Options
Author
Message
getshir
getshir
Posted Monday, September 22, 2008 4:26 PM
Forum 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
Jason Crider
Jason Crider
Posted Monday, September 22, 2008 5:40 PM
SSC Veteran
Group: General Forum Members
Last Login: Friday, May 31, 2013 10:50 AM
Points: 282,
Visits: 2,135
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
Bhuvnesh
Bhuvnesh
Posted Tuesday, September 23, 2008 4:55 AM
SSCrazy
Group: General Forum Members
Last Login: Thursday, June 13, 2013 7:03 AM
Points: 2,562,
Visits: 3,453
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----------
While 1 = 1 (Learning SQL....)
Click to get fast response of your post
Post #574201
RBarryYoung
RBarryYoung
Posted Tuesday, September 23, 2008 7:52 PM
SSCrazy Eights
Group: General Forum Members
Last Login: Wednesday, June 12, 2013 11:17 AM
Points: 9,855,
Visits: 9,376
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
giri_engg2001
giri_engg2001
Posted Wednesday, September 24, 2008 9:34 AM
Forum 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
Glen Sidelnikov
Glen Sidelnikov
Posted Wednesday, September 24, 2008 9:42 AM
Old Hand
Group: General Forum Members
Last Login: Tuesday, January 22, 2013 12:08 PM
Points: 371,
Visits: 794
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
RBarryYoung
RBarryYoung
Posted Wednesday, September 24, 2008 11:02 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Wednesday, June 12, 2013 11:17 AM
Points: 9,855,
Visits: 9,376
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
Glen Sidelnikov
Glen Sidelnikov
Posted Wednesday, September 24, 2008 11:18 AM
Old Hand
Group: General Forum Members
Last Login: Tuesday, January 22, 2013 12:08 PM
Points: 371,
Visits: 794
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
parth83.rawal
parth83.rawal
Posted Friday, October 02, 2009 10:18 AM
Valued Member
Group: General Forum Members
Last Login: Wednesday, March 06, 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
RBarryYoung
RBarryYoung
Posted Friday, October 02, 2009 10:28 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Wednesday, June 12, 2013 11:17 AM
Points: 9,855,
Visits: 9,376
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 »
16 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.