I have a requirement to update 30 columns as test1 null = 33 and 33=55, test2 null = 122 and 122 = 55 so on.....If possible then it would better to update with first value of row 1 by id so that I don't need to search and define each value.
SampleData:
id test1 test2
1 33 122
2 1 122
3 NULL 35
4 3 NULL
5 59 170
6 33 122
ExpectedResult:
id test1 test2
1 55 55
2 1 55
3 33 35
4 3 122
5 59 170
6 55 55
I am trying as following and it also not updating correctly
UPDATE #tmpOne
SET test1 = CASE WHEN test1 IS NULL THEN 33 ELSE 55 END,
test2 = CASE WHEN test2 IS NULL THEN 122 ELSE 55 END
Everyone is welcome for the answer and thanks in advance.