title: Must declare the scalar variable table
body: <p>I have the following SQL:</p>
  
  <pre><code>DECLARE @HospitalReport TABLE (Registrator VARCHAR (20))
  
  INSERT INTO @HospitalReport (Registrator) 
  VALUES("64")
  
  SELECT 
      @HospitalReport.Registrator 
  FROM 
      @HospitalReport
  
  IF Registrator &gt; 0
  BEGIN
      SELECT 
          Database.dbo.Users.Firstname, Database.dbo.Users.Lastname 
      FROM 
          StradaAnv.dbo.Anvandare 
      WHERE 
          Id = Registrator
  
      IF Firstname != NULL AND Lastname != NULL
      BEGIN
          UPDATE @HospitalReport 
          SET Registrator = Firstname + ' ' + Lastname 
          WHERE Registrator = Registrator
      END 
  END
  
  SELECT * FROM @HospitalReport
  </code></pre>
  
  <p>When I run this code, I get the following error:</p>
  
  <blockquote>
    <p>Msg 137, Level 16, State 1, Line 9<br>
    Must declare the scalar variable "@HospitalReport"</p>
  </blockquote>
  
  <p>What I see, I already have declared <code>@HospitalReport</code> as a table?</p>