select sample_value,Sample_GUID,row_number() over(order by sample_value )as rownumber into #AATemp ------建立临时表
from [ZJJK].[dbo].[bus_report_Sample_source] -----从哪张表查询到的数据
declare @i int ,@count int,@sample_value decimal(10,5),@Sample_GUID char(32) -----定义变量
set @i=1
select @count=max(rownumber) from #AATemp
while @i<@count
begin ----开始循环修改
select @sample_value=sample_value,@Sample_GUID=Sample_GUID from #AATemp
update [ZJFoodborne].[dbo].[BusSamples] -----要修改的表
set Sample_Counts=@sample_value -----要修改的字段名称
where Sample_GUID=@Sample_GUID -----条件
set @i=@i+1
end