Project

General

Profile

Data Services #1548 » 1.sql

Script to run Section Tables - 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 Startchainage,Endchainage from LandUse_NR6 where Roadid=@Roadcode and [land Type Code]='WB' order by Startchainage
open c
fetch c into @oldsc,@oldEc
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 LandUse_NR6 set newsc=@newSC ,NewEc=@NewEc where startchainage=@oldsc and Roadid=@Roadcode and Endchainage=@Oldec and [land Type Code]='WB'
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 ,@oldEc

End

close c
deallocate c
(2-2/3)