title: SQL Constraint from a reference table
body: <p>I am building a table for a front end users to use - and would love to alleviate as much error making as possible.</p>
  
  <p>User enters 4 fields, a season from a drop down, and then pick the fiscal year its associated with also in a drop down. (The other two are dates entered by the user).</p>
  
  <p>Both drop down values come from the same place same system table. <code>t_season</code> What I would like to do is once the user selects season lets say <code>16-17 events</code> what I would like to happen is that <code>fyear</code> gets pulled from the data, similar to a trigger but as a constraint. </p>
  
  <p>I've got a constraint to set up/audit create dates - and I would like to build a constraint similar to a create date I have set up on the table.  </p>
  
  <pre><code>ALTER TABLE [dbo].[LTR_PERF_DATES] ADD  CONSTRAINT [DF_LTR_PERF_DATES_create_dt_1__13]  DEFAULT (getdate()) FOR [create_dt]
  </code></pre>
  
  <p>but I'm not sure what to do ... something along the lines of</p>
  
  <pre><code>ALTER TABLE [dbo].[LTR_PERF_DATES] ADD  CONSTRAINT [DF_LTR_PERF_DATES_fyear]  DEFAULT _____ FOR fyear
  </code></pre>
  
  <p>something like this maybe:</p>
  
  <pre><code>ALTER TABLE [dbo].[LTR_PERF_DATES] ADD CONSTRAINT [DF_LTR_PERF_DATES_fyear] FOREIGN KEY [ID] REFERENCES [dbo].[tr_season] ([fyear])
  </code></pre>