title: Checking whether two tables have identical content
body: <p>How can I check and store in variable whether two tables have identical content?</p>
  
  <p>I have table variable with data like</p>
  
  <pre><code>declare @table1 table (id int)
  insert into @table1 (id) values (1), (2), (3)
  </code></pre>
  
  <p>and as the second table I have query</p>
  
  <pre><code>select T.id from SomeTable T
  inner join @table1 T1 on T.id = T1.id
  </code></pre>
  
  <p>the query returns data:</p>
  
  <pre><code>id
  -----
  1
  2
  </code></pre>
  
  <p>In this case I need write false(0) into <code>declare @HasAccess BIT</code> variable.
  When the query returns data:</p>
  
  <pre><code>id
  -----
  1
  2
  3
  </code></pre>
  
  <p>then I need write true(1) into <code>@HasAccess</code></p>