title: Update duplicate data with same unique-identifier
body: <p>I have the following table in my database:</p>
  <p><a href="https://i.stack.imgur.com/cznKq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cznKq.png" alt="enter image description here" /></a></p>
  <p>So I want to generate Unique-identifier and Update the UniqueID column as shown below:</p>
  <p><a href="https://i.stack.imgur.com/IRKt0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IRKt0.png" alt="enter image description here" /></a></p>
  <p>If values of UniqueID are the same, then they must have the same Uniqueidentifier. I have tried to write a CTE as below:</p>
  <pre><code>;WITH Duplicates AS
              (
                  SELECT
                      *,
                      RowNum = ROW_NUMBER() OVER (PARTITION BY UniqueID ORDER BY TypeID)
                  FROM
                      ##Table1
              )
  
              UPDATE ##Table1
              SET UniqueID = NEWID()
              FROM Duplicates d
  </code></pre>
  <p>But am not getting what am looking for. Very knew to the world of CTEs. What is the best way to get the results am looking for?</p>