sqlsql-serverstored-proceduresxp-cmdshell

If I want to execute an executable from a stored procedure, is there any way to do it other than using xp_cmdshell?


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?


Solution

  • 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?