title: Run exe file with parameter from SQL Server
body: <p><a href="https://i.stack.imgur.com/3ynlW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3ynlW.png" alt="enter image description here"></a>I have created a console application and now I want to execute this <code>.exe</code> file from SQL Server. Running this query only gets <code>null</code> output. Please help me.</p>
  
  <pre><code>    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
  </code></pre>