title: How do I launch multiple sqlcmd windows from a batch file?
body: <p>How do I launch multiple sqlcmd windows from a batch file that all point to the same database?  For example, when I run the .bat file I want it to spawn N number of windows based on a parameter that I pass into it (ex. 5).  Each of these 5 windows should open on my desktop and all connect to the same database.  That's what I want to do first.  Once I have that working, I then want to have each of those 5 windows to run a distinct .sql script that performs inserts, queries, updates, deletes, calling stored procedures...essentially emulating a production environment to help us in debugging efforts (under a user load).  I want to see the output of each .sql commend flying by in the sqlcmd window while it is being executed.</p>
  
  <p>I found:</p>
  
  <p><a href="http://hammerora.sourceforge.net/" rel="nofollow">http://hammerora.sourceforge.net/</a></p>
  
  <p>which is a GUI tool that is focused on TPC-C load testing, but it is not exactly what I want.  I bring it up because it is a similar concept that I want to do only driven by batch files on a smaller scale (ex. 20 concurrent users max).  </p>
  
  <p>I created a system like this back in the late 90's for Oracle scalability testing but I've been out of the database business since then and can't remember how to do it and how different it would need to be to support SQL Server.  So I know it is possible in Oracle, but just not sure about SQL Server given the command line tool and scripting capabilities.</p>
  
  <p>Does anyone have any information about what it would take to make this work?</p>
  
  <p>Ex. Create a <code>launch3users.bat</code> file that looks like:</p>
  
  <pre><code>sqlcmd -d MichaelTest -run this 1.sql file
  Pause
  
  sqlcmd -d MichaelTest -run this 2.sql file
  Pause
  
  sqlcmd -d MichaelTest -run this 3.sql file
  Pause
  </code></pre>
  
  <p>where each of those would spawn a sqlcmd window and run the proper .sql script which could do DML operations or called stored procedures.</p>
  
  <p>Thanks,
  Michael</p>