title: Batch script to dynamically pass inputs to a .exe and run recursively
body: <p>I am trying to run a batch script where it will be fetching Values from SQL Server table result set and pass that as an input in a loop to an .EXE in the batch script and run recursively.</p>
  
  <p><strong>Example:</strong> </p>
  
  <pre><code>SQL Query: 
  select Name from sys.tables
  
  SQL Query output: 
  a
  b
  c
  
  /*Now I have to pass the output of sql query values(a,b,c) I got above as an 
  input to Test.exe parameter 3 times in a for or while loop specific to batch 
  script one value at a time and executes the exe. 
  
  Example of values passed to exe looks as below.
  
  
  Test.exe a  -- 1st run in a loop
  Test.exe b  -- 2nd run in a loop
  Test.exe c  -- 3rd run in a loop
  
  -- My code overview or assumption, I would need the below code snippet to be replaced 
  and rewritten in a way it executes successfully using batch script.*/
  
  
  declare @name int
  set @name = count(Name) from sys.tables
  
  
  DECLARE @Counter INT 
  
  SET @Counter=1
  
  WHILE ( @Counter &lt;= @name)
  
  BEGIN
  
      C:\Users&gt; .\Test.exe /Input_From_Sql_result_as_argument @Name 
  
      SET @Counter  = @Counter  + 1
  END
  </code></pre>
  
  <p>I am new to batch scripting, if you can shed some ideas on implementing this in batch script it would be really helpful. Please let me know if I have to share any details..</p>