title: Using a table variable inside of a exists statement
body: <p>I am trying to update a column inside of a table variable based on a condition, the condition being that the ID of the table variable does not exist in a different table:</p>
  
  <pre><code>DECLARE @BugRep TABLE(BugCode VARCHAR(50),DevFirstName VARCHAR(50), DevLastName    VARCHAR(50), BugDate VARCHAR(20), IsValid VARCHAR(1))
  
  UPDATE @BugRep 
  SET IsValid = 'N' WHERE NOT EXISTS(SELECT * FROM BUG b WHERE @BugRep.BUGCODE = b.CODE)
  </code></pre>
  
  <p>When i try to compile the procedure that has these statements, I get a "Must declare the scalar variable "@BugRep" message.</p>
  
  <p>How do i go about using the table variable inside of the NOT EXISTS clause?</p>
  
  <p>I am using SQL Server 2008</p>