title: How to update a column with data from another column in SQL Server?
body: <p>I have a SQL Server table with multiple columns 2 of which are <code>Kwd</code> and <code>UserName</code>. I am trying to update all values in column <code>UserName</code> with values from column <code>Kwd</code>. Both columns are of type <code>nvarchar</code>.</p>
  
  <p>I am using the below query.</p>
  
  <pre><code>UPDATE test_table1 
  SET UserName = Kwd
  </code></pre>
  
  <p>I have also tried</p>
  
  <pre><code>SET a.UserName = B.Kwd 
  FROM test_table1 a 
  INNER JOIN test_table1 b ON a.PelID = b.PelID
  </code></pre>
  
  <p>However it updates all column with value "sa", what could be wrong?</p>
  
  <p>Update 1:</p>
  
  <p>I have tried testing an easier approach to see what will happen When I run the query:</p>
  
  <pre><code>UPDATE test_table1 
  SET UserName = 'test'
  </code></pre>
  
  <p>it still updates all rows with value <code>sa</code></p>