title: How Can I ALTER COLUMN to NOT NULL and ADD PRIMARY KEY in the same SQL
body: <p>I have a column <code>my_id</code> which is already set as <code>varchar(50)</code> <code>NULL</code>. Now I want to alter it to <code>NOT NULL</code> and add it as <code>primary key</code> for that table. Since there is no other primary keys yet.
  I have written like below.</p>
  
  <pre><code>ALTER TABLE my_details
  ALTER COLUMN my_id varchar(50) NOT NULL;
  
  ALTER TABLE my_details
  ADD PRIMARY KEY (my_id); 
  </code></pre>
  
  <p>But I get an error:</p>
  
  <blockquote>
    <p>Cannot define PRIMARY KEY constraint on nullable column in table 'my_details'. Could not create constraint. See previous errors.</p>
  </blockquote>
  
  <p>How to write a single query for this? </p>