title: SQL - Two CHECK condition in one Table
body: <p>I'm trying to implement two <code>CHECK</code> conditions in one table -</p>
  <p>This way it won't work:</p>
  <pre><code>CREATE TABLE example
  (
      ex_id INT IDENTITY(1,1) PRIMARY KEY,
      age TINYINT CHECK (age &gt; 21),
      parent_age TINYINT CHECK (parent_age &gt; age) -- fail on this one
  );
  </code></pre>
  <p>Checking the Microsot Docs &quot;Creating and Modifying CHECK Constraints&quot;</p>
  <pre><code>CREATE TABLE dbo.Vendors 
  (
      VendorID int PRIMARY KEY, 
      VendorName nvarchar (50), 
      CreditRating tinyint
  )
  GO
  
  ALTER TABLE dbo.Vendors 
      ADD CONSTRAINT CK_Vendor_CreditRating
          CHECK (CreditRating &gt;= 1 AND CreditRating &lt;= 5)
  </code></pre>
  <p>I didn't understand what the <code>CK_Vendor_CreditRating</code> is, but I tried :</p>
  <pre><code>CREATE TABLE example
  (
      ex_id INT IDENTITY(1,1) PRIMARY KEY,
      age TINYINT CHECK (age &gt; 21),
      parent_age TINYINT 
  );
  
  ALTER TABLE dbo.example 
      ADD CONSTRAINT CK_example_parent_age
          CHECK (parent_age &gt; age)
  </code></pre>
  <p>Close - but I still get an error:</p>
  <blockquote>
  <p>Msg 547, Level 16, State 0, Line 7</p>
  </blockquote>
  <p>Will be glad for any suggestions.</p>