title: How to access variables in whole SQL script
body: <p>I need to access variables in whole script that is divided to few sections by <code>GO</code> command. How to do that?</p>
  
  <p>Below is source example (that doesn't work):  </p>
  
  <pre><code>--script info (begining of script file)  
  DECLARE @ScriptCode NVARCHAR (20)  = '20120330-01'  
  
  --some queries  
  GO  
  
  --and there I cannot use @ScriptCode variable 
  INSERT INTO DBScriptsHistory(ScriptCode) VALUES(@ScriptCode)  
  </code></pre>