Project

General

Profile

Data Services #1548 » 2.sql

Script to run PointTables - Madhuri Pinky Mendu, 19/12/2024 01:43 PM

 
declare @oldsc int ,@newSC int, @Oldec int ,@NewEc int,@Roadcode int=114
declare c cursor for select chainage from PointAsset_NR6 where Roadid=@Roadcode order by chainage
open c
fetch c into @oldsc
while @@FETCH_STATUS=0
begin
--select @oldsc,@oldEc
select oc,abs(oc-@oldsc) CDiff,Nc into #temp1 from gps_diff where abs(oc-@oldsc)<10

select top 1 @newSC =NC from #temp1 where Cdiff=(Select Min(CDiff) from #temp1)

--select oc,abs(oc-@oldEc) CDiff,Nc into #temp2 from gps_diff where abs(oc-@oldEc)<10

--select top 1 @newEC =NC from #temp2 where Cdiff=(Select Min(CDiff) from #temp2)

update PointAsset_NR6 set newSc=@newSC --,NewEc=@NewEc
where chainage=@oldsc and Roadid=@Roadcode
Drop table #temp1
--Drop table #temp2

--update [tdCondunPaved_Newch114] set newsc=@newSC ,NewEc=@NewEc where startchainage=@oldsc and Roadid=@Roadcode

fetch next from c into @oldsc

End

close c
deallocate c
(3-3/3)