-- Simple illustration for the above updateDECLARE @T_Keyword TABLE( [id] [int] NOT NULL,[sitename] [nvarchar](255) NULL, [List_name] [nvarchar](50) NULL,[keyword] [nvarchar](max) NULL)--i got 2 records for each sitename ex:INSERT INTO @T_KeywordSELECT 1, 'domain.com', 'level1', 'keyword1' union allSELECT 2, 'domain.com', 'level2', 'keyword2' union allSELECT 3, 'domain1.com', 'level1', 'keyword11' union allSELECT 4, 'domain1.com', 'level2', 'keyword12'--I want to update the keyword field which named 'level1' with the one 'level2';WITH cte AS( SELECT *, ROW_NUMBER() OVER(PARTITION BY sitename ORDER BY List_name) RN FROM @T_Keyword )UPDATE c1SET c1.keyword = c2.keywordFROM cte c1 JOIN cte c2 ON c1.Rn = c2.Rn-1 and c1.sitename = c2.sitenameSELECT * FROM @T_Keyword
--Chandu