You can select everything you want to temporary table, clear repeated values and return result set from updated temporary table.
Query might look like this:
select 1 as id, 'aa' as col1, '21' as col2,'ss' as col3,'m' as col4,'p' as col5 into #tmp union select 2, 'aa','21','tt','f','u' union select 3, 'bb','21','ss','f','d' union select 4, 'bb','22','ss','m','d' update t set col1 = case when tp.col1 = t.col1 then '' else t.col1 end, col2 = case when tp.col2 = t.col2 then '' else t.col2 end, col3 = case when tp.col3 = t.col3 then '' else t.col3 end, col4 = case when tp.col4 = t.col4 then '' else t.col4 end, col5 = case when tp.col5 = t.col5 then '' else t.col5 end from #tmp t left join ( select t1.id, max(t2.id) as pid from #tmp t1 join #tmp t2 on t1.id > t2.id group by t1.id ) p on t.id = p.id left join #tmp tp on p.pid = tp.id
Result:
/*------------------------ select top 100 * from #tmp ------------------------*/ id col1 col2 col3 col4 col5 1 aa 21 ss m p 2 tt f u 3 bb ss d 4 22 m
SQL Fiddle