title: How to create foreign key constraint in microsoft sql server 2012?
body: <p>I am trying to create foreign key constraint in microsoft sql server 2012 with following schema:</p>
  
  <pre><code>CREATE TABLE Period
  (
      Period_ID int IDENTITY(1,1) NOT NULL PRIMARY KEY,
      Training_History_Start_Period datetime NULL,
      Training_History_End_Period datetime NULL,
      Training_Target_Start_Period datetime NULL,
      Training_Target_End_Period datetime NULL,
      Scoring_History_Start_Period datetime NULL,
      Scoring_History_End_Period datetime NULL,
      Scoring_Target_Start_Period datetime NULL,
      Scoring_Target_End_Period datetime NULL
  );
  
  CREATE TABLE RiskScore
  (
      Period_ID int FOREIGN KEY REFERENCES Period(Period_ID),
      Driver_ID int NULL,
      Risk_Score numeric(10,5) NULL,
      Run_on datetime NULL
  );
  </code></pre>
  
  <p>At the time of inserting data into DB, Period table taking desired data but RiskScore table is taking in Period_ID column. This column is not taking Period_ID from Period table.</p>
  
  <p>Someone help me please.</p>
  
  <p>Thanks in advance.</p>