Hi, i have data in my table as belowSID RED BLUE GREEN HIGH_COLOR1 12 15 5 NULL2 45 56 6 NULL3 67 5 7 NULL4 78 7 79 NULL
I am looking for output as belowSID RED BLUE GREEN HIGH_COLOR1 12 15 5 BLUE,RED,GREEN2 45 56 6 BLUE,RED,GREEN 3 67 5 7 RED,GREEN,BLUE4 78 7 79 GREEN,RED,BLUE
I have written query to do this. But i am getting same output for all rows. i am getting result as belowSID RED BLUE GREEN HIGH_COLOR1 12 15 5 BLUE,RED,GREEN2 45 56 6 BLUE,RED,GREEN 3 67 5 7 BLUE,RED,GREEN4 78 7 79 BLUE,RED,GREEN
My Query is as below.While EXISTS (Select Top 1 * from Colors Where High_Color is null)Begin Update Colors Set High_Color =(SELECT theCol + ',' FROM (SELECT top 1 * FROM colors Where High_Color is null) AS t1 UNPIVOT (theValue FOR theCol IN (RED,BLUE,GREEN)) AS u1 ORDER BY theValue DESC FOR XML PATH(''))EndMy Table Contains around 300 million rows. Pls tell me whether the way i am going to update the table is right? or any other query which doesn't performance.(Its a one time process). And one more thing..with my query i am getting output appending with comma.But i dont want comma appended at last.(Remove bold red color comma in result)Ex: BLUE,RED,GREEN,RegardsMNG