1 --Analog Data2 IF object_id('tempdb: #t')>0 DROP TABLE#t3 SELECT * into#t4 from (5 SELECT '1'Id2030G265H830K'G*h+h*k'Gs0TT6 UNION All7 SELECT '2'Id2030G0H0K'g*4'Gs0TT8 UNION All9 SELECT '3'Id2030G265H0K'(g+h) * *'Gs0TTTen UNION All One SELECT '4'Id2030G265H0K'(g+h) * *'Gs0tt) T A --Raw Data - SELECT * from#t - the --variables - DECLARE @i int,@n INT - DECLARE @gs VARCHAR( -) - DECLARE @sql VARCHAR(MAX) + - --Categorize by formula category + IF object_id('tempdb: #tt')>0 DROP TABLE#tt A SELECTRow_number () Over(ORDER byGS) rowID at , GS - into#tt - from#t - GROUP byGS - - --Traverse by formula category in SELECT @i=MIN(ROWID),@n=MAX(ROWID) from#tt - while(@i<=@n) to BEGIN + SELECT @gs=Gs from#ttWHERErowID=@i - SET @sql='update #t set tt='+@gs+'where gs=" "+@gs+" '"--Generate Script the EXEC(@sql)--execute script, can print see effect * SET @i=@i+1 $ ENDPanax Notoginseng --post-treatment effects - SELECT * from#t
Effect preview: