title: How to run multiple SQL scripts using a batch file?
body: <p>I have a case where i have got 10+ <code>SQL script</code>.</p>
  
  <p>I don't want to go and run all my scripts 1 by 1.</p>
  
  <p>Is there a way that i can run all my scripts in succession in <code>SQL Management studio</code>.</p>
  
  <p>I found <a href="http://dotnetanalysis.blogspot.com/2011/04/run-multiple-sql-scripts.html" rel="noreferrer">this</a> post. Creating a batch file seems easier.</p>
  
  <p>This is all you need:</p>
  
  <pre><code>@echo off
  ECHO %USERNAME% started the batch process at %TIME%  &gt;output.txt
  
  
  for %%f in (*.sql) do (
   (
  sqlcmd.exe  -S servername -E   -d databasename -i %%f &gt;&gt;output.txt
  )
  
  
  pause
  </code></pre>
  
  <p>Replacing servername and databasename, but it seems to be not working.</p>
  
  <p>Any ideas?</p>