title: Stored Procedure calling variables from table
body: <p>I have a stored procedure that uses a variable ID, I have a list of valid IDs in a table. </p>
  
  <p>I'm trying to write a stored procedure that runs a specific piece of code if the ID exists in table. I'm just not sure of the syntax. </p>
  
  <p>Below is my pseudo-code of what I'm attempting to do.</p>
  
  <pre><code>IF
  @ID = possible id IN (SELECT DISTINCT ID FROM [dbo].ID_TABLE WHERE ID = 'valid')
        SELECT * FROM dbo.[results]
  
  ELSE
  
  SELECT * FROM dbo.[otherresults]
  </code></pre>
  
  <p>I'm using SQL Server </p>