title: SQL: how to enforce that only a single column is set in a group of columns
body: <p>In SQL, is there a way to enforce that only one column out of a group of columns has a value, and the others are null?  Maybe a constraint or trigger?  This type of thing might be for a lookup table, but are there any alternate table designs that might accomplish this better?</p>
  
  <p>For example:</p>
  
  <pre><code>ID    OtherTable1ID    OtherTable2ID    OtherTable3ID
  -----------------------------------------------------
  1     23               NULL             NULL
  2     NULL             45               NULL
  3     33               55               NULL   -- NOT ALLOWED
  </code></pre>
  
  <p>The main issue is that these columns are all FKs to other tables, so I can't collapse them down to a single column.</p>
  
  <p>I'm using SQL Server, but any answer will do.</p>