title: Using batch variable in sqlcmd query
body: <p>I'm trying to create a batch to execute a few sql script and some queries. I use sqlcmd in my batch like this :</p>
  
  <pre><code>@echo off
  sqlcmd -S server -U user -P password -Q query
  </code></pre>
  
  <p>As I will execute different queries on the same server, I'd like to replace the server statement with a variable. So I could write something like this :</p>
  
  <pre><code>@echo off
  SET server=192.X.X.X
  sqlcmd -S server -U user -P password -Q first query
  sqlcmd -S server -U user -P password -Q second query
  </code></pre>
  
  <p>I found this question on SO but I'm still unable to understand how that works :</p>
  
  <p><a href="https://stackoverflow.com/questions/32227390/sqlcmd-using-batch-variable-in-query">SQLCMD using batch variable in query</a></p>
  
  <p>Does anyone have an idea ?</p>
  
  <p>Thanks a lot! </p>