Run exe file with parameter from SQL Server

enter image description here I created a console application, and now I want to execute this .exe file with SQL Server. Executing this query gets only null . Please help me.

  DECLARE @CMDSQL VARCHAR(1000), @Reportname VARCHAR(100), @TerminalCode VARCHAR(10), @FinYear VARCHAR(10) SET @Reportname =('05 - Import Load Delivery') SET @FinYear='2017-18' SET @TerminalCode='BOM' SET @CMDSQL = '"D:\ExportToExcel.exe" ' + @Reportname + ' ' + @TerminalCode + ' ' + @FinYear --print @CMDSQL Exec master..xp_cmdshell @CMDSQL 
+5
source share
1 answer

Try the following:

 SET @CMDSQL = 'CMD /S /C " "D:\ExportToExcel.exe" "' + @ReportName + '" "' + @TerminalCode + '" "' + @FinYear + '" "' 

It is important to specify individual parameters as suggested by @DanGuzman.

+3
source

All Articles