title: Custom function with check constraint SQL Server 2008
body: <p>I working with SQL Server 2008 and I have two existing tables, <code>venues</code> and <code>events</code>. </p>
  
  <p>I am trying to create a custom function with a check constraint to make sure that the integer in the <code>event_expected_attendance</code> column in the <code>events</code> table is always less than or equal to the <code>venue_max_capacity</code> integer in the <code>venues</code> table. </p>
  
  <p>I am struggling with the syntax of a custom function as well as the join statement since the check constraint is between two tables. </p>
  
  <p>Thanks for the help! I will answer any additional questions quickly.</p>