title: Error: "Must declare the scalar variable" for insert statements in multiple database
body: <p>I created a SQL script to add an entry in different database. However, when I run the script through SQL Server Management Studio.</p>
  
  <pre><code>declare @address varchar(50)
  set @address = 'Hope'
  
  use DB1
  go
  
  insert into Address
   values (@address)
  go
  
  use DB2
  go
  
  insert into Address
   values (@address)
  go
  </code></pre>
  
  <p>I got the following error:</p>
  
  <blockquote>
    <p>Must declare the scalar variable '@address'</p>
  </blockquote>
  
  <p>At this point, I'm totally confused because I've declared the variable <code>@address</code> before executing the <code>insert</code> statement. Is it because I'm traversing different database?</p>
  
  <p>As of now, I've just put the actual value in the <code>insert</code> statement just for the sake of completing the task, though I wondered what caused the error.</p>