title: SqlServer - search if a list of values is fully contained on table
body: <p>I have a sql table and a list of values to search.</p>
  
  <p>if at least all the elements of the table are contained in the list, then I must return the Ticket Id (it means that I will update this record). Otherwise, I will return null (it means that it will be a new registration).</p>
  
  <p>For example</p>
  
  <p><a href="https://i.stack.imgur.com/pWZue.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pWZue.png" alt="enter image description here"></a></p>
  
  <p>Use cases:</p>
  
  <ul>
  <li>If I search for this elements: C1, C3, C6, it will be an update and I will get ticketid 1</li>
  <li>If I search for this elements: C8, C3, C6, C10, it will be a create and I will get null as return value </li>
  </ul>
  
  <p>A list of values is a Predefined-Type with a column, in this case, @ElementsToSearch with a column Value </p>
  
  <pre><code>SELECT T.Id
  FROM 
      Ticket t
  INNER JOIN 
      TicketValue TL ON TL.TicketId = T.Id
  LEFT OUTER JOIN
      @ElementsToSearch ES ON ES.Value = TL.Value
  WHERE
      ES.Value is null
  </code></pre>
  
  <p>thank you</p>