title: Check Constraint – only allow one column to be true if another column is true
body: <p>Take the following example table:</p>
  
  <pre><code>CREATE TABLE [dbo].[tbl_Example](
      [PageID] [int] IDENTITY(1,1) NOT NULL,
      [RequireLogin] [bit] NOT NULL,
      [RequireAdmin] [bit] NOT NULL,
      [HideIfLoggedIn] [bit] NOT NULL
  )
  </code></pre>
  
  <p>How would one rewrite the above to include check constraints as follows:</p>
  
  <ul>
  <li>Force <code>[RequireAdmin]</code> to be <strong>False</strong> if <code>[RequireLogin]</code> is <strong>False</strong> (i.e only allow <code>[RequireAdmin]</code> to be <strong>True</strong> if <code>[RequireLogin]</code> is <strong>True</strong> whilst allowing <code>[RequireLogin]</code> to be <strong>True</strong> and <code>[RequireAdmin]</code> to be <strong>False</strong></li>
  <li>Only allow <code>[HideIfLoggedIn]</code> to be <strong>True</strong> if <code>[RequireLogin]</code> is <strong>False</strong></li>
  </ul>