title: T-SQL to search ID in a table
body: <p>I have a mapping table below and I want to check either ID exists in the corresponding Table or not. For example: check ID 001 in &quot;xxabc&quot; database table and return &quot;Yes&quot; if table has 001 ID present else &quot;No&quot;.</p>
  <pre><code>ID              TableName
  --------------------------
  001             xxabc
  003             xxabc
  004             xxpqr
  009             xxghi   
  </code></pre>