到目前为止,这是我能掌握的:
declare @i int = 7;
declare @lat float;
declare @lng float;
declare @point ???; -- what type?
declare @location table(lat float, lng float)
insert @location values (32.097218, 34.770438199999944)
insert @location values (32.083847, 34.775618)
insert @location values (32.1600788, 34.771902)
insert @location values (31.9914283, 34.80780099999993)
insert @location values (32.1574281, 34.775191800000016)
insert @location values (29.5543212, 34.89448429999993)
insert @location values (32.8018919, 34.96268420000001)
while @i > 0
begin
-- this is a wrong way to do it
set @point = (select top (1) * from @location);
-- must set @lat and @lng here somehow, based on the
-- one row selected above. Deleting here is not
-- mandatory, but may be used, if needed.
delete top (1) from @location;
update top (1) rest_tbl
set lat = @lat, lng = @lng
where lat is null and private_label_id = 3
set @i = @i - 1
end;
请不要介意我创建@location
变量的部分——在现实世界中,它是一个实际的表,我只是将它用于 PoC。