Ransom self update

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- Ransom self update

declare @TableX table(ENDE_NO_Address varchar(10))
insert into @TableX values ('1'),('2'),(null),('4'),('5');


WITH cte AS (
SELECT
    ROW_NUMBER() OVER (ORDER BY NEWID()) AS n1,
    ROW_NUMBER() OVER (ORDER BY (select NEWID())) AS n2,
    ENDE_NO_Address
FROM @TableX
)
update C1 set
  ENDE_NO_Address = C2.ENDE_NO_Address
from cte as C1
  inner join cte as C2
    on C1.n1 = C2.n2

select *
from @TableX

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results