title: Unable to set foreign key for my computed column
body: <p>I can't set the foreign key for my advertisement table or should I say how do I add datatype for my computed column in employer table ? error details below</p>
  
  <pre><code>CREATE Table Employer
  ( 
      No Int  NOT NULL IDENTITY(1,1),
      EmployerID AS 'EID'+ CAST(No as VARCHAR(50)) PERSISTED NOT NULL ,
        CONSTRAINT PK_Employer PRIMARY KEY CLUSTERED(EmployerID),
      EUsername CHAR(20) NOT NULL,
      EPassword CHAR(20) NOT NULL,
      Name VARCHAR(20) NOT NULL,
      Contact_Number INT NOT NULL,
      Email CHAR(20) NOT NULL,
      Company_Name CHAR(30) NOT NULL,
      Current_Position VARCHAR(30) NULL
  );
  
  CREATE Table Advertisement
  (
      No Int  NOT NULL IDENTITY(1,1),
      AdvertisementID AS 'AID'+ CAST(No as VARCHAR(10)) PERSISTED ,
        CONSTRAINT PK_Advertisement PRIMARY KEY CLUSTERED(AdvertisementID) ,
      Employer_ID VARCHAR(10) Foreign Key References Employer(EmployerID) NOT NULL,
      Company_Name VARCHAR(30) NOT NULL,
      Company_Location CHAR(30) NULL,
      Job_Position VARCHAR(30)NOT NULL,
      Job_Description VARCHAR(100) NULL,
      Skills_Requirement VARCHAR(100) NULL,
      Education_Requirement CHAR(50) NOT NULL,
      Salary CHAR(20) NOT NULL
  );
  </code></pre>
  
  <p>This is the error I keep getting : </p>
  
  <blockquote>
    <p>Msg 1753, Level 16, State 0, Line 27<br>
    Column 'Employer.EmployerID' is not the same length or scale as referencing column 'Advertisement.EmployerID' in foreign key 'FK__Advertise__Emplo__07C12930'. Columns participating in a foreign key relationship must be defined with the same length and scale.</p>
    
    <p>Msg 1750, Level 16, State 0, Line 27<br>
    Could not create constraint or index. See previous errors.</p>
  </blockquote>