title: SQL - Only UNIQUE or PRIMARY KEY constraints can be created on computed columns
body: <p>I am trying to create a table with a computed column called profileID, however when I try this:</p>
  
  <pre><code>CREATE TABLE Profiles 
  (
      [id] [int] IDENTITY(1,1) NOT NULL,
      [profileID] AS ((id * 19379 - 62327) % 99991) NOT NULL
  )
  </code></pre>
  
  <p>However when I goto create it, I get this error:</p>
  
  <blockquote>
    <p>Only UNIQUE or PRIMARY KEY constraints can be created on computed columns, while CHECK, FOREIGN KEY, and NOT NULL constraints require that computed columns be persisted.</p>
  </blockquote>
  
  <p>I've tried to adjust the profileID line to this</p>
  
  <pre><code>[profileID] as ( (id * 19379 - 62327) % 99991) NOT NULL UNIQUE
  </code></pre>
  
  <p>But I still get the same error.</p>
  
  <p>FYI I have another column called id and its the primary key and is unique and auto_incremented.</p>