title: Column in table is of a type that is invalid for use as a key column in an index
body: <p>I have a table where I am storing employee details. I want to alter the table and set one of the column <code>emp_code</code> as primary key. Its datatype is <code>nvarchar(max)</code>, but I am not able to set it as primary key.</p>
  
  <p>I run the following query : </p>
  
  <pre><code>ALTER TABLE user_master
  ADD PRIMARY KEY (emp_code)
  </code></pre>
  
  <p>but it gives me an error :</p>
  
  <blockquote>
    <p><em>Msg 1919, Level 16, State 1, Line 1</em><br>
    <em>Column <code>emp_code</code> in table <code>user_master</code> is of a type that is invalid for use as a key column in an index.</em><br>
    <em>Msg 1750, Level 16, State 0, Line 1</em><br>
    <em>Could not create constraint. See previous errors.</em></p>
  </blockquote>
  
  <p>How can I overcome this?</p>