I have an executable on the server. I want to execute that .exe file in my stored procedure. What is the correct way to do it other than using xp_cmdshell?
Asked
Active
Viewed 1,755 times
0
-
2The more important question of course is: why do you want to execute an .exe from a stored proc? If I was your DBA, I wouldn't let you. – Mitch Wheat Jan 02 '19 at 06:03
-
1Sounds like a bad idea. But maybe it can be done via CLR. – sticky bit Jan 02 '19 at 06:06
1 Answers
1
If you have to do this, I would create a Job and call it from your stored procedure using sp_start_job: https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-start-job-transact-sql?view=sql-server-2017
There is a simple example here on how to create the job to do it: How execute exe file from sql agent or job?

JMabee
- 2,230
- 2
- 9
- 13