ALTER PROCEDURE [dbo].[GetBridgeInventoryGridByFilter] --exec [dbo].[GetBridgeInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL --exec [dbo].[GetBridgeInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL --exec [dbo].[GetBridgeInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL --exec [dbo].[GetBridgeInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'pranusha', 'W',NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF @userType = 'H' BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year', Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END else bd.Remarks END else ld.Remarks END 'Remarks' ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMaterialType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END ELSE IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL) BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year',Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END 'Remark s' FROM [BMS].[LocationDetails] LD LEFT OUTER JOIN [BMS].[BridgeDetails] bd ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT JOIN BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType LEFT JOIN BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype --LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.SolidorHallow LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END ELSE IF (@userType = 'D' and @hType is NULL) BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year',Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END 'Remark s' FROM [BMS].[LocationDetails] LD LEFT OUTER JOIN [BMS].[BridgeDetails] bd ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT JOIN BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType LEFT JOIN BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype --LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.SolidorHallow LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END ELSE BEGIN IF @hType = 'C' BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year',Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END 'Remark s' FROM [BMS].[LocationDetails] LD LEFT OUTER JOIN [BMS].[BridgeDetails] bd ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT JOIN BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType LEFT JOIN BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype --LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.SolidorHallow LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND lm.Circle = @hTypeVal AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END ELSE IF @hType = 'D' BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year',Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END 'Remark s' FROM [BMS].[LocationDetails] LD LEFT OUTER JOIN [BMS].[BridgeDetails] bd ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT JOIN BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType LEFT JOIN BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype --LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.SolidorHallow LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND lm.Division = @hTypeVal AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END IF @hType = 'W' BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year',Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END 'Remark s' FROM [BMS].[LocationDetails] LD LEFT OUTER JOIN [BMS].[BridgeDetails] bd ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT JOIN BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType LEFT JOIN BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype --LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.SolidorHallow LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT sdr.LinkCode FROM NM.LinkMaster sdr WHERE Circle IN (SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal)) AND lm.Circle IN (SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END END END GO ALTER PROCEDURE [dbo].[GetBridgeInventoryDataByFilter] --exec [dbo].[GetBridgeInventoryDataByFilter] NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL --exec [dbo].[GetBridgeInventoryDataByFilter] NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL --exec [dbo].[GetBridgeInventoryDataByFilter] NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL --exec [dbo].[GetBridgeInventoryDataByFilter] NULL,NULL,NULL,NULL,NULL,'pranusha', 'W',NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL) BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF (@userType = 'D' and @hType is NULL) BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF (@hType = 'C' OR @hType = 'W') BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'D' BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'MLA' BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode inner join NM.MLAConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MLACode = ISNULL(@hTypeVal,mcr.MLACode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY ld.RoadCode, Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt inner join NM.MLAConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MLACode = ISNULL(@hTypeVal,mcr.MLACode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY ld.RoadCode, Chainage END ELSE IF @hType = 'MP' BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY ld.RoadCode, Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY ld.RoadCode, bd.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY ld.RoadCode, Chainage END ELSE IF @userType = 'H' BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END END GO ALTER PROCEDURE [dbo].[GetBridgeInventoryByFilter] --EXEC [dbo].[GetBridgeInventoryByFilter] 'SHIM',null,'BR:NH030:0000.100',0,1000 --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,1,NULL,NULL,NULL,'satya','H','D','RBD35' --EXEC [dbo].[GetBridgeInventoryByFilter] 'MDR_RBD01_004',NULL,NULL,4000,5000,'demogen','C',NULL,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] 'SH021',2,NULL,26000,38000,'div','D',NULL,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'dinesh',W,NULL,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'satya',NULL,H,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'krish',NULL,H,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'krish',NULL,H,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'krish',NULL,NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF (@userType = 'C' and @hType is NULL) BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd ,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge ,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF (@userType = 'D' and @hType is NULL) BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge ,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF (@userType = 'W' and @hType is NULL) BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd ,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE BEGIN IF @hType = 'C' BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd ,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'D' BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge ,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode' --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'W' BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd ,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'MLA' BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'MP' BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd ,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,LPT.Description AS SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,LPMT.Description AS PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe ,LBC.Description AS BrdgCatg ,LCS.Description as PrtctWrksCondSev ,LCE.Description as PrtctWrksCondExt ,bd.SideSlpPitchArea ,bd.FloorPrtctArea ,bd.WtrwayBlockage FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial LEFT OUTER JOIN bms.LKPTBrdgCatg LBC ON BC.BrdgCatgType=BD.BrdgCatg LEFT OUTER JOIN bms.LKPTPipeMtrlType LPMT ON LPMT.PipeMtrlType=BD.PipeMtrl LEFT OUTER JOIN BMS.LKPTPitchingType LPT ON LPT.PitchingTypeCondType=BD.SideSlopePitchType LEFT OUTER JOIN bms.LKPTCondSev LCS ON LCS.CondSevType=BD.PrtctWrksCondSev LEFT OUTER JOIN bms.LKPTCondExt LCE ON LCE.CondExtType=BD.PrtctWrksCondExt WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END END END GO ALTER PROCEDURE [dbo].[GetPierDetailsByFilter] -- exec [dbo].[GetPierDetailsByFilter] NULL,NULL,NULL,NULL,NULL,'krish', NULL,NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF @userType = 'C' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrPierDetID], [BridgeCode], [PierNo],pt.Description as [PierType],awrt.Description as [PierMaterial], [ClmnsThcktop], [ClmnsThckbttm], [PierTopLen], [PierBttmLen], [PierHeight], [ClmnsCount], [UniformCapHeight], [CapWidth], [TaperedCapHeight], [CapLenTop],abt.Description as [PierBearingsType], [BearingsCount], ft.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,sm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,wt.Description as WellFundtionType , hd.[Remarks],cwt.Description CutEaseWaterType,'Approved' ApprovalStatus FROM [BMS].[PierDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.PierBearingsType LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial left outer join [BMS].[LKPTFoundType] ft on ft.FoundType=hd.FndtionType left outer join [BMS].[LKPTSmcMtrl] sm on sm.SmcMtrlType=hd.SmcRstnrMtrl left outer join bms.LKPTAbutMaterial am on am.AbutMaterialType=hd.FndtionMtrlType left outer join [BMS].[LKPTWellType] wt on wt.WellType=hd.WellFundtionType WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS] --.LKPTAbutBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAb --utBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSubStrPierDetID], null [BridgeCode], SurveyYear, null [SpanNo], null [PierNo], null [PierType], null [PierMaterial], null [ThicknesstopM], null [ThicknessbottomM], null -- [LengthattopM], null [LengthatbottomM], null [HeightM], null [NoofColumns], null [DiaOfColumnsM], null [SpacingofColumnsM], null [HeightofColumnM], null [UniformheightofcapM], null -- [WidthofcapM], null [TaperedheightofcapM], null [LengthofcapM], null [Cuteasewaterisprovided], null [CutEaseWaterType], null [CutEaseWaterThicknessM], null [BearingPier], null -- [NoOfBearings], null [erthquakrestrindampnsprovd], null [Remarks],null PierTypeDescription,null CutEaseWaterTypeDescription,null BearingPierDescription,null PierMaterialDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection , null[BrdgSubStrPierDetID], null [BridgeCode], null [PierNo], null [PierType], null [PierMaterial], null [ClmnsThcktop], null [ClmnsThckbttm], null [PierTopLen], null[PierBttmLen], null[PierHeight], null[ClmnsCount], null[UniformCapHeight], null[CapWidth], null[TaperedCapHeight], null[CapLenTop],null[PierBearingsType], null[BearingsCount], null FndtionType ,null RaftWidth ,null Raftlength ,null NoofPiles ,null WlPlDiameter ,null WellDepth ,null FndtionMtrlType ,null CapLenBttm ,null BearingsPrvd ,null BearingsVisible ,null SmcRstnrPrvd ,null SmcRstnrMtrl ,null SmcRstnrLoc ,null PileWidth ,null WellFundtionType,null [Remarks],null CutEaseWaterType,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging]) ) --AND bridgeid NOT IN (SELECT bridgeid FROM [BMS].[LocationDetails])) END ELSE IF @userType = 'D' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrPierDetID], [BridgeCode], [PierNo],pt.Description as [PierType],awrt.Description as [PierMaterial], [ClmnsThcktop], [ClmnsThckbttm], [PierTopLen], [PierBttmLen], [PierHeight], [ClmnsCount], [UniformCapHeight], [CapWidth], [TaperedCapHeight], [CapLenTop],abt.Description as [PierBearingsType], [BearingsCount], ft.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,sm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,wt.Description as WellFundtionType , hd.[Remarks],cwt.Description CutEaseWaterType,'Approved' ApprovalStatus FROM [BMS].[PierDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.PierBearingsType LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial left outer join [BMS].[LKPTFoundType] ft on ft.FoundType=hd.FndtionType left outer join [BMS].[LKPTSmcMtrl] sm on sm.SmcMtrlType=hd.SmcRstnrMtrl left outer join bms.LKPTAbutMaterial am on am.AbutMaterialType=hd.FndtionMtrlType left outer join [BMS].[LKPTWellType] wt on wt.WellType=hd.WellFundtionType WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS] --.LKPTAbutBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) -- AND ld.LinkCode IN (SELECT LinkCode -- FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSubStrPierDetID], null [BridgeCode], SurveyYear, null [SpanNo], null [PierNo], null [PierType], null [PierMaterial], null [ThicknesstopM], null [ThicknessbottomM], null -- [LengthattopM], null [LengthatbottomM], null [HeightM], null [NoofColumns], null [DiaOfColumnsM], null [SpacingofColumnsM], null [HeightofColumnM], null [UniformheightofcapM], null -- [WidthofcapM], null [TaperedheightofcapM], null [LengthofcapM], null [Cuteasewaterisprovided], null [CutEaseWaterType], null [CutEaseWaterThicknessM], null [BearingPier], null -- [NoOfBearings], null [erthquakrestrindampnsprovd], null [Remarks],null PierTypeDescription,null CutEaseWaterTypeDescription,null BearingPierDescription,null PierMaterialDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) -- AND ld.LinkCode IN (SELECT LinkCode -- FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection , null[BrdgSubStrPierDetID], null [BridgeCode],null [PierNo], null [PierType], null [PierMaterial], null [ClmnsThcktop], null [ClmnsThckbttm], null [PierTopLen], null[PierBttmLen], null[PierHeight], null[ClmnsCount], null[UniformCapHeight], null[CapWidth], null[TaperedCapHeight], null[CapLenTop],null[PierBearingsType], null[BearingsCount], null FndtionType ,null RaftWidth ,null Raftlength ,null NoofPiles ,null WlPlDiameter ,null WellDepth ,null FndtionMtrlType ,null CapLenBttm ,null BearingsPrvd ,null BearingsVisible ,null SmcRstnrPrvd ,null SmcRstnrMtrl ,null SmcRstnrLoc ,null PileWidth ,null WellFundtionType,null [Remarks],null CutEaseWaterType,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging]) ) --AND bridgeid NOT IN (SELECT bridgeid FROM [BMS].[LocationDetails])) END ELSE IF @userType = 'W' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrPierDetID], [BridgeCode], [PierNo],pt.Description as [PierType],awrt.Description as [PierMaterial], [ClmnsThcktop], [ClmnsThckbttm], [PierTopLen], [PierBttmLen], [PierHeight], [ClmnsCount], [UniformCapHeight], [CapWidth], [TaperedCapHeight], [CapLenTop],abt.Description as [PierBearingsType], [BearingsCount], ft.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,sm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,wt.Description as WellFundtionType , hd.[Remarks],cwt.Description CutEaseWaterType,'Approved' ApprovalStatus FROM [BMS].[PierDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.PierBearingsType LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial left outer join [BMS].[LKPTFoundType] ft on ft.FoundType=hd.FndtionType left outer join [BMS].[LKPTSmcMtrl] sm on sm.SmcMtrlType=hd.SmcRstnrMtrl left outer join bms.LKPTAbutMaterial am on am.AbutMaterialType=hd.FndtionMtrlType left outer join [BMS].[LKPTWellType] wt on wt.WellType=hd.WellFundtionType WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS] --.LKPTAbutBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbu --tBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSubStrPierDetID], null [BridgeCode], SurveyYear, null [SpanNo], null [PierNo], null [PierType], null [PierMaterial], null [ThicknesstopM], null [ThicknessbottomM], null -- [LengthattopM], null [LengthatbottomM], null [HeightM], null [NoofColumns], null [DiaOfColumnsM], null [SpacingofColumnsM], null [HeightofColumnM], null [UniformheightofcapM], null -- [WidthofcapM], null [TaperedheightofcapM], null [LengthofcapM], null [Cuteasewaterisprovided], null [CutEaseWaterType], null [CutEaseWaterThicknessM], null [BearingPier], null -- [NoOfBearings], null [erthquakrestrindampnsprovd], null [Remarks],null PierTypeDescription,null CutEaseWaterTypeDescription,null BearingPierDescription,null PierMaterialDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection , null[BrdgSubStrPierDetID], null [BridgeCode], null [PierNo], null [PierType], null [PierMaterial], null [ClmnsThcktop], null [ClmnsThckbttm], null [PierTopLen], null[PierBttmLen], null[PierHeight], null[ClmnsCount], null[UniformCapHeight], null[CapWidth], null[TaperedCapHeight], null[CapLenTop],null[PierBearingsType], null[BearingsCount], null FndtionType ,null RaftWidth ,null Raftlength ,null NoofPiles ,null WlPlDiameter ,null WellDepth ,null FndtionMtrlType ,null CapLenBttm ,null BearingsPrvd ,null BearingsVisible ,null SmcRstnrPrvd ,null SmcRstnrMtrl ,null SmcRstnrLoc ,null PileWidth ,null WellFundtionType,null [Remarks],null CutEaseWaterType,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging]) ) END ELSE BEGIN IF @hType = 'C' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrPierDetID], [BridgeCode], [PierNo],pt.Description as [PierType],awrt.Description as [PierMaterial], [ClmnsThcktop], [ClmnsThckbttm], [PierTopLen], [PierBttmLen], [PierHeight], [ClmnsCount], [UniformCapHeight], [CapWidth], [TaperedCapHeight], [CapLenTop],abt.Description as [PierBearingsType], [BearingsCount], ft.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,sm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,wt.Description as WellFundtionType , hd.[Remarks],cwt.Description CutEaseWaterType,'Approved' ApprovalStatus FROM [BMS].[PierDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.PierBearingsType LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial left outer join [BMS].[LKPTFoundType] ft on ft.FoundType=hd.FndtionType left outer join [BMS].[LKPTSmcMtrl] sm on sm.SmcMtrlType=hd.SmcRstnrMtrl left outer join bms.LKPTAbutMaterial am on am.AbutMaterialType=hd.FndtionMtrlType left outer join [BMS].[LKPTWellType] wt on wt.WellType=hd.WellFundtionType WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS] --.LKPTAbutBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAb --utBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSubStrPierDetID], null [BridgeCode], SurveyYear, null [SpanNo], null [PierNo], null [PierType], null [PierMaterial], null [ThicknesstopM], null [ThicknessbottomM], null -- [LengthattopM], null [LengthatbottomM], null [HeightM], null [NoofColumns], null [DiaOfColumnsM], null [SpacingofColumnsM], null [HeightofColumnM], null [UniformheightofcapM], null -- [WidthofcapM], null [TaperedheightofcapM], null [LengthofcapM], null [Cuteasewaterisprovided], null [CutEaseWaterType], null [CutEaseWaterThicknessM], null [BearingPier], null -- [NoOfBearings], null [erthquakrestrindampnsprovd], null [Remarks],null PierTypeDescription,null CutEaseWaterTypeDescription,null BearingPierDescription,null PierMaterialDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection , null[BrdgSubStrPierDetID], null [BridgeCode], null [PierNo], null [PierType], null [PierMaterial], null [ClmnsThcktop], null [ClmnsThckbttm], null [PierTopLen], null[PierBttmLen], null[PierHeight], null[ClmnsCount], null[UniformCapHeight], null[CapWidth], null[TaperedCapHeight], null[CapLenTop],null[PierBearingsType], null[BearingsCount], null FndtionType ,null RaftWidth ,null Raftlength ,null NoofPiles ,null WlPlDiameter ,null WellDepth ,null FndtionMtrlType ,null CapLenBttm ,null BearingsPrvd ,null BearingsVisible ,null SmcRstnrPrvd ,null SmcRstnrMtrl ,null SmcRstnrLoc ,null PileWidth ,null WellFundtionType,null [Remarks],null CutEaseWaterType,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging]) ) END ELSE IF @hType = 'D' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrPierDetID], [BridgeCode], [PierNo],pt.Description as [PierType],awrt.Description as [PierMaterial], [ClmnsThcktop], [ClmnsThckbttm], [PierTopLen], [PierBttmLen], [PierHeight], [ClmnsCount], [UniformCapHeight], [CapWidth], [TaperedCapHeight], [CapLenTop],abt.Description as [PierBearingsType], [BearingsCount], ft.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,sm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,wt.Description as WellFundtionType , hd.[Remarks],cwt.Description CutEaseWaterType,'Approved' ApprovalStatus FROM [BMS].[PierDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.PierBearingsType LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial left outer join [BMS].[LKPTFoundType] ft on ft.FoundType=hd.FndtionType left outer join [BMS].[LKPTSmcMtrl] sm on sm.SmcMtrlType=hd.SmcRstnrMtrl left outer join bms.LKPTAbutMaterial am on am.AbutMaterialType=hd.FndtionMtrlType left outer join [BMS].[LKPTWellType] wt on wt.WellType=hd.WellFundtionType WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS] --.LKPTAbutBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbu --tBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSubStrPierDetID], null [BridgeCode], SurveyYear, null [SpanNo], null [PierNo], null [PierType], null [PierMaterial], null [ThicknesstopM], null [ThicknessbottomM], null -- [LengthattopM], null [LengthatbottomM], null [HeightM], null [NoofColumns], null [DiaOfColumnsM], null [SpacingofColumnsM], null [HeightofColumnM], null [UniformheightofcapM], null -- [WidthofcapM], null [TaperedheightofcapM], null [LengthofcapM], null [Cuteasewaterisprovided], null [CutEaseWaterType], null [CutEaseWaterThicknessM], null [BearingPier], null -- [NoOfBearings], null [erthquakrestrindampnsprovd], null [Remarks],null PierTypeDescription,null CutEaseWaterTypeDescription,null BearingPierDescription,null PierMaterialDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection , null[BrdgSubStrPierDetID], null [BridgeCode], null [PierNo], null [PierType], null [PierMaterial], null [ClmnsThcktop], null [ClmnsThckbttm], null [PierTopLen], null[PierBttmLen], null[PierHeight], null[ClmnsCount], null[UniformCapHeight], null[CapWidth], null[TaperedCapHeight], null[CapLenTop],null[PierBearingsType], null[BearingsCount], null FndtionType ,null RaftWidth ,null Raftlength ,null NoofPiles ,null WlPlDiameter ,null WellDepth ,null FndtionMtrlType ,null CapLenBttm ,null BearingsPrvd ,null BearingsVisible ,null SmcRstnrPrvd ,null SmcRstnrMtrl ,null SmcRstnrLoc ,null PileWidth ,null WellFundtionType,null [Remarks],null CutEaseWaterType,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging]) ) END ELSE IF @hType = 'W' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrPierDetID], [BridgeCode], [PierNo],pt.Description as [PierType],awrt.Description as [PierMaterial], [ClmnsThcktop], [ClmnsThckbttm], [PierTopLen], [PierBttmLen], [PierHeight], [ClmnsCount], [UniformCapHeight], [CapWidth], [TaperedCapHeight], [CapLenTop],abt.Description as [PierBearingsType], [BearingsCount], ft.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,sm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,wt.Description as WellFundtionType , hd.[Remarks],cwt.Description CutEaseWaterType,'Approved' ApprovalStatus FROM [BMS].[PierDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.PierBearingsType LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial left outer join [BMS].[LKPTFoundType] ft on ft.FoundType=hd.FndtionType left outer join [BMS].[LKPTSmcMtrl] sm on sm.SmcMtrlType=hd.SmcRstnrMtrl left outer join bms.LKPTAbutMaterial am on am.AbutMaterialType=hd.FndtionMtrlType left outer join [BMS].[LKPTWellType] wt on wt.WellType=hd.WellFundtionType WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) /* Commented on 11/26/2020*/ AND LD.RoadCode IN (SELECT sdr.Roadcode FROM NM.LinkMaster sdr WHERE Circle IN(SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal)) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS] --.LKPTAbutBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbu --tBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSubStrPierDetID], null [BridgeCode], SurveyYear, null [SpanNo], null [PierNo], null [PierType], null [PierMaterial], null [ThicknesstopM], null [ThicknessbottomM], null -- [LengthattopM], null [LengthatbottomM], null [HeightM], null [NoofColumns], null [DiaOfColumnsM], null [SpacingofColumnsM], null [HeightofColumnM], null [UniformheightofcapM], null -- [WidthofcapM], null [TaperedheightofcapM], null [LengthofcapM], null [Cuteasewaterisprovided], null [CutEaseWaterType], null [CutEaseWaterThicknessM], null [BearingPier], null -- [NoOfBearings], null [erthquakrestrindampnsprovd], null [Remarks],null PierTypeDescription,null CutEaseWaterTypeDescription,null BearingPierDescription,null PierMaterialDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection , null[BrdgSubStrPierDetID], null [BridgeCode], null [PierNo], null [PierType], null [PierMaterial], null [ClmnsThcktop], null [ClmnsThckbttm], null [PierTopLen], null[PierBttmLen], null[PierHeight], null[ClmnsCount], null[UniformCapHeight], null[CapWidth], null[TaperedCapHeight], null[CapLenTop],null[PierBearingsType], null[BearingsCount], null FndtionType ,null RaftWidth ,null Raftlength ,null NoofPiles ,null WlPlDiameter ,null WellDepth ,null FndtionMtrlType ,null CapLenBttm ,null BearingsPrvd ,null BearingsVisible ,null SmcRstnrPrvd ,null SmcRstnrMtrl ,null SmcRstnrLoc ,null PileWidth ,null WellFundtionType,null [Remarks],null CutEaseWaterType,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) /* Commented on 11/26/2020*/ AND LD.RoadCode IN (SELECT sdr.Roadcode FROM NM.LinkMaster sdr WHERE Circle IN(SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging]) ) END ELSE IF @hType = 'MLA' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrPierDetID], [BridgeCode], [PierNo],pt.Description as [PierType],awrt.Description as [PierMaterial], [ClmnsThcktop], [ClmnsThckbttm], [PierTopLen], [PierBttmLen], [PierHeight], [ClmnsCount], [UniformCapHeight], [CapWidth], [TaperedCapHeight], [CapLenTop],abt.Description as [PierBearingsType], [BearingsCount], ft.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,sm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,wt.Description as WellFundtionType , hd.[Remarks],cwt.Description CutEaseWaterType,'Approved' ApprovalStatus FROM [BMS].[PierDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.PierBearingsType LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial left outer join [BMS].[LKPTFoundType] ft on ft.FoundType=hd.FndtionType left outer join [BMS].[LKPTSmcMtrl] sm on sm.SmcMtrlType=hd.SmcRstnrMtrl left outer join bms.LKPTAbutMaterial am on am.AbutMaterialType=hd.FndtionMtrlType left outer join [BMS].[LKPTWellType] wt on wt.WellType=hd.WellFundtionType WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS] --.LKPTAbutBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbu --tBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSubStrPierDetID], null [BridgeCode], SurveyYear, null [SpanNo], null [PierNo], null [PierType], null [PierMaterial], null [ThicknesstopM], null [ThicknessbottomM], null -- [LengthattopM], null [LengthatbottomM], null [HeightM], null [NoofColumns], null [DiaOfColumnsM], null [SpacingofColumnsM], null [HeightofColumnM], null [UniformheightofcapM], null -- [WidthofcapM], null [TaperedheightofcapM], null [LengthofcapM], null [Cuteasewaterisprovided], null [CutEaseWaterType], null [CutEaseWaterThicknessM], null [BearingPier], null -- [NoOfBearings], null [erthquakrestrindampnsprovd], null [Remarks],null PierTypeDescription,null CutEaseWaterTypeDescription,null BearingPierDescription,null PierMaterialDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection , null[BrdgSubStrPierDetID], null [BridgeCode], null [PierNo], null [PierType], null [PierMaterial], null [ClmnsThcktop], null [ClmnsThckbttm], null [PierTopLen], null[PierBttmLen], null[PierHeight], null[ClmnsCount], null[UniformCapHeight], null[CapWidth], null[TaperedCapHeight], null[CapLenTop],null[PierBearingsType], null[BearingsCount], null FndtionType ,null RaftWidth ,null Raftlength ,null NoofPiles ,null WlPlDiameter ,null WellDepth ,null FndtionMtrlType ,null CapLenBttm ,null BearingsPrvd ,null BearingsVisible ,null SmcRstnrPrvd ,null SmcRstnrMtrl ,null SmcRstnrLoc ,null PileWidth ,null WellFundtionType,null [Remarks],null CutEaseWaterType,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging]) ) END ELSE IF @hType = 'MP' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrPierDetID], [BridgeCode], [PierNo],pt.Description as [PierType],awrt.Description as [PierMaterial], [ClmnsThcktop], [ClmnsThckbttm], [PierTopLen], [PierBttmLen], [PierHeight], [ClmnsCount], [UniformCapHeight], [CapWidth], [TaperedCapHeight], [CapLenTop],abt.Description as [PierBearingsType], [BearingsCount], ft.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,sm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,wt.Description as WellFundtionType , hd.[Remarks],cwt.Description CutEaseWaterType,'Approved' ApprovalStatus FROM [BMS].[PierDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.PierBearingsType LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial left outer join [BMS].[LKPTFoundType] ft on ft.FoundType=hd.FndtionType left outer join [BMS].[LKPTSmcMtrl] sm on sm.SmcMtrlType=hd.SmcRstnrMtrl left outer join bms.LKPTAbutMaterial am on am.AbutMaterialType=hd.FndtionMtrlType left outer join [BMS].[LKPTWellType] wt on wt.WellType=hd.WellFundtionType WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS] --.LKPTAbutBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbu --tBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSubStrPierDetID], null [BridgeCode], SurveyYear, null [SpanNo], null [PierNo], null [PierType], null [PierMaterial], null [ThicknesstopM], null [ThicknessbottomM], null -- [LengthattopM], null [LengthatbottomM], null [HeightM], null [NoofColumns], null [DiaOfColumnsM], null [SpacingofColumnsM], null [HeightofColumnM], null [UniformheightofcapM], null -- [WidthofcapM], null [TaperedheightofcapM], null [LengthofcapM], null [Cuteasewaterisprovided], null [CutEaseWaterType], null [CutEaseWaterThicknessM], null [BearingPier], null -- [NoOfBearings], null [erthquakrestrindampnsprovd], null [Remarks],null PierTypeDescription,null CutEaseWaterTypeDescription,null BearingPierDescription,null PierMaterialDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection , null[BrdgSubStrPierDetID], null [BridgeCode], null [PierNo], null [PierType], null [PierMaterial], null [ClmnsThcktop], null [ClmnsThckbttm], null [PierTopLen], null[PierBttmLen], null[PierHeight], null[ClmnsCount], null[UniformCapHeight], null[CapWidth], null[TaperedCapHeight], null[CapLenTop],null[PierBearingsType], null[BearingsCount], null FndtionType ,null RaftWidth ,null Raftlength ,null NoofPiles ,null WlPlDiameter ,null WellDepth ,null FndtionMtrlType ,null CapLenBttm ,null BearingsPrvd ,null BearingsVisible ,null SmcRstnrPrvd ,null SmcRstnrMtrl ,null SmcRstnrLoc ,null PileWidth ,null WellFundtionType,null [Remarks],null CutEaseWaterType,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE ld.RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging]) ) END Else BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrPierDetID], [BridgeCode], [PierNo],pt.Description as [PierType],awrt.Description as [PierMaterial], [ClmnsThcktop], [ClmnsThckbttm], [PierTopLen], [PierBttmLen], [PierHeight], [ClmnsCount], [UniformCapHeight], [CapWidth], [TaperedCapHeight], [CapLenTop],abt.Description as [PierBearingsType], [BearingsCount], ft.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,sm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,wt.Description as WellFundtionType , hd.[Remarks],cwt.Description CutEaseWaterType,'Approved' ApprovalStatus FROM [BMS].[PierDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.PierBearingsType LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial left outer join [BMS].[LKPTFoundType] ft on ft.FoundType=hd.FndtionType left outer join [BMS].[LKPTSmcMtrl] sm on sm.SmcMtrlType=hd.SmcRstnrMtrl left outer join bms.LKPTAbutMaterial am on am.AbutMaterialType=hd.FndtionMtrlType left outer join [BMS].[LKPTWellType] wt on wt.WellType=hd.WellFundtionType WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS] --.LKPTAbutBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT -- [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], -- [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection, -- [BrdgSubStrPierDetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [PierNo], [PierType], [PierMaterial], [ThicknesstopM], [ThicknessbottomM], -- [LengthattopM], [LengthatbottomM], [HeightM], [NoofColumns], [DiaOfColumnsM], [SpacingofColumnsM], [HeightofColumnM], [UniformheightofcapM], -- [WidthofcapM], [TaperedheightofcapM], [LengthofcapM], [Cuteasewaterisprovided], [CutEaseWaterType], [CutEaseWaterThicknessM], [BearingPier], -- [NoOfBearings], [erthquakrestrindampnsprovd], hd.[Remarks],pt.Description PierTypeDescription,cwt.Description CutEaseWaterTypeDescription,abt.Description BearingPierDescription,awrt.Description PierMaterialDescription, -- (CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[PierDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbu --tBearType abt ON abt.AbutBearType=hd.BearingPier LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSubStrPierDetID], null [BridgeCode], SurveyYear, null [SpanNo], null [PierNo], null [PierType], null [PierMaterial], null [ThicknesstopM], null [ThicknessbottomM], null -- [LengthattopM], null [LengthatbottomM], null [HeightM], null [NoofColumns], null [DiaOfColumnsM], null [SpacingofColumnsM], null [HeightofColumnM], null [UniformheightofcapM], null -- [WidthofcapM], null [TaperedheightofcapM], null [LengthofcapM], null [Cuteasewaterisprovided], null [CutEaseWaterType], null [CutEaseWaterThicknessM], null [BearingPier], null -- [NoOfBearings], null [erthquakrestrindampnsprovd], null [Remarks],null PierTypeDescription,null CutEaseWaterTypeDescription,null BearingPierDescription,null PierMaterialDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection , null[BrdgSubStrPierDetID], null [BridgeCode], null [PierNo], null [PierType], null [PierMaterial], null [ClmnsThcktop], null [ClmnsThckbttm], null [PierTopLen], null[PierBttmLen], null[PierHeight], null[ClmnsCount], null[UniformCapHeight], null[CapWidth], null[TaperedCapHeight], null[CapLenTop],null[PierBearingsType], null[BearingsCount], null FndtionType ,null RaftWidth ,null Raftlength ,null NoofPiles ,null WlPlDiameter ,null WellDepth ,null FndtionMtrlType ,null CapLenBttm ,null BearingsPrvd ,null BearingsVisible ,null SmcRstnrPrvd ,null SmcRstnrMtrl ,null SmcRstnrLoc ,null PileWidth ,null WellFundtionType,null [Remarks],null CutEaseWaterType,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[PierDetails_Staging]) ) END END END GO ALTER PROCEDURE [dbo].[GetPierDetailsByBridgeCode] --'BR:NH030:0000.500' ( @bridgeCode VARCHAR(100)=NULL, @surveyYear VARCHAR(100)=NULL, @spanNo VARCHAR(10) = NULL, @tableFlag VARCHAR(10)=NULL ) AS BEGIN IF @tableFlag = 'M' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrPierDetID], [BridgeCode], [PierNo],pt.Description as [PierType],awrt.Description as [PierMaterial], [ClmnsThcktop], [ClmnsThckbttm], [PierTopLen], [PierBttmLen], [PierHeight], [ClmnsCount], [UniformCapHeight], [CapWidth], [TaperedCapHeight], [CapLenTop],abt.Description as [PierBearingsType], [BearingsCount], ft.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,sm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,wt.Description as WellFundtionType , hd.[Remarks],cwt.Description CutEaseWaterType,'Approved' ApprovalStatus FROM [BMS].[PierDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.PierBearingsType LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial left outer join [BMS].[LKPTFoundType] ft on ft.FoundType=hd.FndtionType left outer join [BMS].[LKPTSmcMtrl] sm on sm.SmcMtrlType=hd.SmcRstnrMtrl left outer join bms.LKPTAbutMaterial am on am.AbutMaterialType=hd.FndtionMtrlType left outer join [BMS].[LKPTWellType] wt on wt.WellType=hd.WellFundtionType WHERE BridgeCode = @bridgeCode --AND hd.SurveyYear = @surveyYear --AND SpanNo=@spanNo END ELSE BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrPierDetID], [BridgeCode], [PierNo],pt.Description as [PierType],awrt.Description as [PierMaterial], [ClmnsThcktop], [ClmnsThckbttm], [PierTopLen], [PierBttmLen], [PierHeight], [ClmnsCount], [UniformCapHeight], [CapWidth], [TaperedCapHeight], [CapLenTop],abt.Description as [PierBearingsType], [BearingsCount], ft.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,sm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,wt.Description as WellFundtionType , hd.[Remarks],cwt.Description CutEaseWaterType,'Approved' ApprovalStatus FROM [BMS].[PierDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTPierType pt ON pt.LKPTPierType=hd.PierType LEFT OUTER JOIN [BMS].LKPTCutWtrType cwt ON cwt.CutWtrType=hd.CutEaseWaterType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.PierBearingsType LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType awrt ON awrt.AbutWallRailMaterType=hd.PierMaterial left outer join [BMS].[LKPTFoundType] ft on ft.FoundType=hd.FndtionType left outer join [BMS].[LKPTSmcMtrl] sm on sm.SmcMtrlType=hd.SmcRstnrMtrl left outer join bms.LKPTAbutMaterial am on am.AbutMaterialType=hd.FndtionMtrlType left outer join [BMS].[LKPTWellType] wt on wt.WellType=hd.WellFundtionType WHERE BridgeCode = @bridgeCode --AND hd.SurveyYear = @surveyYear --AND SpanNo=@spanNo END END GO ALTER PROCEDURE [dbo].[GetSuperStructureDetailsByFilter] --exec [dbo].[GetSuperStructureDetailsByFilter] NULL,NULL,NULL,NULL,NULL,'krish', NULL,NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF @userType = 'C' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ld.DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription , BrdgSupStrdetID ,BridgeCode ,SpanNo ,LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,hd.Remarks ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,hd.DateofInspection , 'Approved' ApprovalStatus FROM [BMS].[SuperStructureDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure --LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab --LEFT OUTER JOIN [BMS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType --LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [B --MS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [BMS].LKPT --StlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription, --null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection --, null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription ,null BrdgSupStrdetID ,null BridgeCode ,null SpanNo ,null LongGirderCount ,null LongGirderSpacing ,null LongGirderDepth ,null LongGirderWidth ,null CrossGirdersCount ,null MonolithicCrossGirder ,null ArchCountinSpan ,null ArchSpace ,null ArchSupportThickness ,null ArchCrownThickness ,null Remarks ,null SpanLen ,null SpanTopWidth ,null SpanBttmWidth ,null SpanThickness ,null CrossGirderDepth ,null CrossGirderThick ,null MainSpanLen ,null CantileverSpanLen ,null SuspendedSpanLen ,null PylonCableCount ,null ArchDepth ,null DateofInspection ,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging]) ) --AND bridgeid NOT IN (SELECT bridgeid FROM [BMS].[LocationDetails])) END ELSE IF @userType = 'D' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ld.DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription , BrdgSupStrdetID ,BridgeCode ,SpanNo ,LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,hd.Remarks ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,hd.DateofInspection , 'Approved' ApprovalStatus FROM [BMS].[SuperStructureDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure --LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab --LEFT OUTER JOIN [BMS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType --LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [B --MS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Divis --ion IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [BMS].LKPT --StlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Divis --ion IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription, --null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection --, null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription ,null BrdgSupStrdetID ,null BridgeCode ,null SpanNo ,null LongGirderCount ,null LongGirderSpacing ,null LongGirderDepth ,null LongGirderWidth ,null CrossGirdersCount ,null MonolithicCrossGirder ,null ArchCountinSpan ,null ArchSpace ,null ArchSupportThickness ,null ArchCrownThickness ,null Remarks ,null SpanLen ,null SpanTopWidth ,null SpanBttmWidth ,null SpanThickness ,null CrossGirderDepth ,null CrossGirderThick ,null MainSpanLen ,null CantileverSpanLen ,null SuspendedSpanLen ,null PylonCableCount ,null ArchDepth ,null DateofInspection ,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging]) ) --AND bridgeid NOT IN (SELECT bridgeid FROM [BMS].[LocationDetails])) END ELSE IF @userType = 'W' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ld.DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription , BrdgSupStrdetID ,BridgeCode ,SpanNo ,LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,hd.Remarks ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,hd.DateofInspection , 'Approved' ApprovalStatus FROM [BMS].[SuperStructureDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure --LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab --LEFT OUTER JOIN [BMS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType --LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [B --MS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [BMS].LKPT --StlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection --, null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription ,null BrdgSupStrdetID ,null BridgeCode ,null SpanNo ,null LongGirderCount ,null LongGirderSpacing ,null LongGirderDepth ,null LongGirderWidth ,null CrossGirdersCount ,null MonolithicCrossGirder ,null ArchCountinSpan ,null ArchSpace ,null ArchSupportThickness ,null ArchCrownThickness ,null Remarks ,null SpanLen ,null SpanTopWidth ,null SpanBttmWidth ,null SpanThickness ,null CrossGirderDepth ,null CrossGirderThick ,null MainSpanLen ,null CantileverSpanLen ,null SuspendedSpanLen ,null PylonCableCount ,null ArchDepth ,null DateofInspection ,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging]) ) --AND bridgeid NOT IN (SELECT bridgeid FROM [BMS].[LocationDetails])) END ELSE BEGIN IF @hType = 'C' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ld.DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription , BrdgSupStrdetID ,BridgeCode ,SpanNo ,LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,hd.Remarks ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,hd.DateofInspection , 'Approved' ApprovalStatus FROM [BMS].[SuperStructureDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure --LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab --LEFT OUTER JOIN [BMS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType --LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem WHERE RoadCode = ISNULL(@roadCode,RoadCode)AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [B --MS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode)AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [BMS].LKPT --StlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode)AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE RoadCode = ISNULL(@roadCode,RoadCode)AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection --, null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription , null BrdgSupStrdetID ,null BridgeCode ,null SpanNo ,null LongGirderCount ,null LongGirderSpacing ,null LongGirderDepth ,null LongGirderWidth ,null CrossGirdersCount ,null MonolithicCrossGirder ,null ArchCountinSpan ,null ArchSpace ,null ArchSupportThickness ,null ArchCrownThickness ,null Remarks ,null SpanLen ,null SpanTopWidth ,null SpanBttmWidth ,null SpanThickness ,null CrossGirderDepth ,null CrossGirderThick ,null MainSpanLen ,null CantileverSpanLen ,null SuspendedSpanLen ,null PylonCableCount ,null ArchDepth ,null DateofInspection ,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE RoadCode = ISNULL(@roadCode,RoadCode)AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging]) ) --AND bridgeid NOT IN (SELECT bridgeid FROM [BMS].[LocationDetails])) END ELSE IF @hType = 'D' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ld.DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription , BrdgSupStrdetID ,BridgeCode ,SpanNo ,LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,hd.Remarks ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,hd.DateofInspection , 'Approved' ApprovalStatus FROM [BMS].[SuperStructureDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure --LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab --LEFT OUTER JOIN [BMS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType --LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [B --MS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription,s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description Stru --cturalSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [BMS].LKPT --StlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescripti --on -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection --, null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription ,null BrdgSupStrdetID ,null BridgeCode ,null SpanNo ,null LongGirderCount ,null LongGirderSpacing ,null LongGirderDepth ,null LongGirderWidth ,null CrossGirdersCount ,null MonolithicCrossGirder ,null ArchCountinSpan ,null ArchSpace ,null ArchSupportThickness ,null ArchCrownThickness ,null Remarks ,null SpanLen ,null SpanTopWidth ,null SpanBttmWidth ,null SpanThickness ,null CrossGirderDepth ,null CrossGirderThick ,null MainSpanLen ,null CantileverSpanLen ,null SuspendedSpanLen ,null PylonCableCount ,null ArchDepth ,null DateofInspection,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging]) ) --AND bridgeid NOT IN (SELECT bridgeid FROM [BMS].[LocationDetails])) END ELSE IF @hType = 'W' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ld.DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription , BrdgSupStrdetID ,BridgeCode ,SpanNo ,LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,hd.Remarks ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,hd.DateofInspection , 'Approved' ApprovalStatus FROM [BMS].[SuperStructureDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure --LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab --LEFT OUTER JOIN [BMS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType --LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem WHERE RoadCode = ISNULL(@roadCode,RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) /* Commented on 11/26/2020*/ AND ld.RoadCode IN (SELECT sdr.Roadcode FROM NM.LinkMaster sdr WHERE Circle IN(SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal)) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription,s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description Stru --cturalSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [B --MS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription,s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description Stru --cturalSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [BMS].LKPT --StlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescripti --on -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection --, null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription ,null BrdgSupStrdetID ,null BridgeCode ,null SpanNo ,null LongGirderCount ,null LongGirderSpacing ,null LongGirderDepth ,null LongGirderWidth ,null CrossGirdersCount ,null MonolithicCrossGirder ,null ArchCountinSpan ,null ArchSpace ,null ArchSupportThickness ,null ArchCrownThickness ,null Remarks ,null SpanLen ,null SpanTopWidth ,null SpanBttmWidth ,null SpanThickness ,null CrossGirderDepth ,null CrossGirderThick ,null MainSpanLen ,null CantileverSpanLen ,null SuspendedSpanLen ,null PylonCableCount ,null ArchDepth ,null DateofInspection,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE RoadCode = ISNULL(@roadCode,RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) /* Commented on 11/26/2020*/ AND ld.RoadCode IN (SELECT sdr.Roadcode FROM NM.LinkMaster sdr WHERE Circle IN(SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging]) ) --AND bridgeid NOT IN (SELECT bridgeid FROM [BMS].[LocationDetails])) END ELSE IF @hType = 'MLA' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ld.DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription , BrdgSupStrdetID ,BridgeCode ,SpanNo ,LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,hd.Remarks ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,hd.DateofInspection, 'Approved' ApprovalStatus FROM [BMS].[SuperStructureDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure --LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab --LEFT OUTER JOIN [BMS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType --LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription,s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description Str --ucturalSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [B --MS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription,s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description Stru --cturalSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [BMS].LKPT --StlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescripti --on -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection --, null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription ,null BrdgSupStrdetID ,null BridgeCode ,null SpanNo ,null LongGirderCount ,null LongGirderSpacing ,null LongGirderDepth ,null LongGirderWidth ,null CrossGirdersCount ,null MonolithicCrossGirder ,null ArchCountinSpan ,null ArchSpace ,null ArchSupportThickness ,null ArchCrownThickness ,null Remarks ,null SpanLen ,null SpanTopWidth ,null SpanBttmWidth ,null SpanThickness ,null CrossGirderDepth ,null CrossGirderThick ,null MainSpanLen ,null CantileverSpanLen ,null SuspendedSpanLen ,null PylonCableCount ,null ArchDepth ,null DateofInspection,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging]) ) END ELSE IF @hType = 'MP' BEGIN SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ld.DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription , BrdgSupStrdetID ,BridgeCode ,SpanNo ,LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,hd.Remarks ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,hd.DateofInspection, 'Approved' ApprovalStatus FROM [BMS].[SuperStructureDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure --LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab --LEFT OUTER JOIN [BMS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType --LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription,s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description Stru --cturalSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [B --MS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription,s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description Stru --cturalSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [BMS].LKPT --StlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescripti --on -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection --, null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription ,null BrdgSupStrdetID ,null BridgeCode ,null SpanNo ,null LongGirderCount ,null LongGirderSpacing ,null LongGirderDepth ,null LongGirderWidth ,null CrossGirdersCount ,null MonolithicCrossGirder ,null ArchCountinSpan ,null ArchSpace ,null ArchSupportThickness ,null ArchCrownThickness ,null Remarks ,null SpanLen ,null SpanTopWidth ,null SpanBttmWidth ,null SpanThickness ,null CrossGirderDepth ,null CrossGirderThick ,null MainSpanLen ,null CantileverSpanLen ,null SuspendedSpanLen ,null PylonCableCount ,null ArchDepth ,null DateofInspection ,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[AbutmentDetails_Staging]) ) END Else Begin SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ld.DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription, --s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description StructuralSystemDescription , BrdgSupStrdetID ,BridgeCode ,SpanNo ,LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,hd.Remarks ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,hd.DateofInspection, 'Approved' ApprovalStatus FROM [BMS].[SuperStructureDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure --LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab --LEFT OUTER JOIN [BMS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType --LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeCode) --UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription,s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description Stru --cturalSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails_Staging] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [B --MS].LKPTStlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- ,[BrdgSupStrdetID], [BridgeCode], hd.[SurveyYear], [SpanNo], [Typeofsuperstructure], [DeckSlab], [DeckSlabThicknessM], -- [LongitudinalGirdersNos], [LongitudinalGirdersSpacingM], [LongitudinalGirdersDepthM], [LongitudinalGirdersWidthM], -- [CrossGirdersNos], [Crsgirdmonolthkwtdkslb], [Numberofarchineachspan], [CentretoCentreSpacingofArchM], -- [ArchDepthofspandrelatsupportM], [ArchDepthofspandrelatCrownM], [SteelMembersConnectionType], [DateofInventory], -- [Dimsteelmem], [Material], [DeckslabtransversallyPrestressed], hd.[Remarks], [StructuralSystem], st.Description TypeofsuperstructureDescription,s.Description DeckSlabDescription,m.Description SteelMembersConnectionTypeDescription,ss.Description Str --ucturalSystemDescription -- ,(CASE WHEN hd.ApprovalStatus IS NULL THEN 'PendingForApproval' ELSE hd.ApprovalStatus END) AS 'ApprovalStatus' -- FROM [BMS].[SuperStructureDetails_Staging] hd -- LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTSupStructType st ON st.SupStructType=hd.Typeofsuperstructure LEFT OUTER JOIN [BMS].LKPTSlabType s ON s.SlabType=hd.DeckSlab LEFT OUTER JOIN [BMS].LKPT --StlMemConnectType m ON m.StlMemConnectType=hd.SteelMembersConnectionType LEFT OUTER JOIN [BMS].LKPTStructSystem ss ON ss.StructSystemType=hd.StructuralSystem -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) -- AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) -- AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeCode) -- UNION --SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] -- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection -- , null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescripti --on -- ,'New' AS 'ApprovalStatus' -- FROM [BMS].[LocationDetails_Staging] ld -- WHERE RoadCode = ISNULL(@roadCode,RoadCode) -- AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) -- AND BridgeID = ISNULL(@bridgeCode,BridgeID) -- AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[SuperStructureDetails]) -- AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[SuperStructureDetails_Staging])) UNION SELECT [LocationId],[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',[LinkCode], [Direction] ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection --, null[BrdgSupStrdetID], null [BridgeCode], SurveyYear, null [SpanNo], null [Typeofsuperstructure], null [DeckSlab], null [DeckSlabThicknessM], null -- [LongitudinalGirdersNos], null [LongitudinalGirdersSpacingM], null [LongitudinalGirdersDepthM], null [LongitudinalGirdersWidthM], null -- [CrossGirdersNos], null [Crsgirdmonolthkwtdkslb], null [Numberofarchineachspan], null [CentretoCentreSpacingofArchM], null -- [ArchDepthofspandrelatsupportM], null [ArchDepthofspandrelatCrownM], null [SteelMembersConnectionType], null [DateofInventory], null -- [Dimsteelmem], null [Material], null [DeckslabtransversallyPrestressed], null [Remarks], null [StructuralSystem], null TypeofsuperstructureDescription,null DeckSlabDescription,null SteelMembersConnectionTypeDescription,null StructuralSystemDescription ,null BrdgSupStrdetID ,null BridgeCode ,null SpanNo ,null LongGirderCount ,null LongGirderSpacing ,null LongGirderDepth ,null LongGirderWidth ,null CrossGirdersCount ,null MonolithicCrossGirder ,null ArchCountinSpan ,null ArchSpace ,null ArchSupportThickness ,null ArchCrownThickness ,null Remarks ,null SpanLen ,null SpanTopWidth ,null SpanBttmWidth ,null SpanThickness ,null CrossGirderDepth ,null CrossGirderThick ,null MainSpanLen ,null CantileverSpanLen ,null SuspendedSpanLen ,null PylonCableCount ,null ArchDepth ,null DateofInspection,'New' AS 'ApprovalStatus' FROM [BMS].[LocationDetails] ld WHERE RoadCode = ISNULL(@roadCode,RoadCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND (bridgeid NOT IN (SELECT bridgecode FROM [BMS].[SuperStructureDetails]) --AND bridgeid NOT IN (SELECT bridgecode FROM [BMS].[SuperStructureDetails_Staging]) ) --AND bridgeid NOT IN (SELECT bridgeid FROM [BMS].[LocationDetails])) END END END GO ALTER PROCEDURE [dbo].[GetSuperStructureDetailsByBridgeCode] ( @bridgeCode VARCHAR(100)=NULL, @surveyYear VARCHAR(100)=NULL, @spanNo VARCHAR(10) = NULL, @tableFlag VARCHAR(10)=NULL ) AS BEGIN IF @tableFlag = 'M' BEGIN --SELECT [BrdgSupStrdetID] ,[BridgeCode],hd.[SurveyYear],[SpanNo] -- ,[Typeofsuperstructure],sst.Description 'TypeofsuperstructureDescription',[DeckSlab],st.Description 'DeckSlabDescription',[DeckSlabThicknessM],[LongitudinalGirdersNos],[LongitudinalGirdersSpacingM],[LongitudinalGirdersDepthM] -- ,[LongitudinalGirdersWidthM],[CrossGirdersNos],[Crsgirdmonolthkwtdkslb],[Numberofarchineachspan],[CentretoCentreSpacingofArchM],[ArchDepthofspandrelatsupportM] -- ,[ArchDepthofspandrelatCrownM],[SteelMembersConnectionType], ct.Description 'SteelMembersConnectionTypeDescription',[DateofInventory],[Dimsteelmem],[Material],[DeckslabtransversallyPrestressed] -- ,hd.[Remarks],[StructuralSystem], ss.Description 'StructuralSystemDescription' SELECT BrdgSupStrdetID ,BridgeCode ,SpanNo ,LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,HD.Remarks ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,HD.DateofInspection FROM [BMS].[SuperStructureDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN BMS.LKPTSupStructType sst ON hd.Typeofsuperstructure = sst.SupStructType --LEFT OUTER JOIN BMS.LKPTSlabType st ON hd.DeckSlab = st.SlabType --LEFT OUTER JOIN BMS.LKPTStlMemConnectType ct ON hd.SteelMembersConnectionType = ct.StlMemConnectType --LEFT OUTER JOIN BMS.LKPTStructSystem ss ON hd.StructuralSystem = ss.StructSystemType WHERE BridgeCode = @bridgeCode --AND hd.SurveyYear = @surveyYear END ELSE BEGIN --SELECT [BrdgSupStrdetID] ,[BridgeCode],hd.[SurveyYear],[SpanNo] -- ,[Typeofsuperstructure],sst.Description 'TypeofsuperstructureDescription',[DeckSlab],st.Description 'DeckSlabDescription',[DeckSlabThicknessM],[LongitudinalGirdersNos],[LongitudinalGirdersSpacingM],[LongitudinalGirdersDepthM] -- ,[LongitudinalGirdersWidthM],[CrossGirdersNos],[Crsgirdmonolthkwtdkslb],[Numberofarchineachspan],[CentretoCentreSpacingofArchM],[ArchDepthofspandrelatsupportM] -- ,[ArchDepthofspandrelatCrownM],[SteelMembersConnectionType], ct.Description 'SteelMembersConnectionTypeDescription',[DateofInventory],[Dimsteelmem],[Material],[DeckslabtransversallyPrestressed] -- ,hd.[Remarks],[StructuralSystem], ss.Description 'StructuralSystemDescription' SELECT BrdgSupStrdetID ,BridgeCode ,SpanNo ,LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,HD.Remarks ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,HD.DateofInspection FROM [BMS].[SuperStructureDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN BMS.LKPTSupStructType sst ON hd.Typeofsuperstructure = sst.SupStructType --LEFT OUTER JOIN BMS.LKPTSlabType st ON hd.DeckSlab = st.SlabType --LEFT OUTER JOIN BMS.LKPTStlMemConnectType ct ON hd.SteelMembersConnectionType = ct.StlMemConnectType --LEFT OUTER JOIN BMS.LKPTStructSystem ss ON hd.StructuralSystem = ss.StructSystemType WHERE BridgeCode = @bridgeCode --AND hd.SurveyYear = @surveyYear END END GO ALTER PROCEDURE [dbo].[GetspanInventoryGridByFilter] --EXEC [dbo].[GetspanInventoryGridByFilter] 'NH030',null,'BR:NH030:0000.100',0,1000 --exec [dbo].[GetspanInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL --exec [dbo].[GetspanInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'pranusha', 'W',NULL,NULL --exec [dbo].[GetspanInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL --exec [dbo].[GetspanInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN if @bridgeType='' set @bridgeType=NULL if @bridgeCode='' set @bridgeCode=NULL if @StartChainage='' set @StartChainage=NULL if @EndChainage='' set @EndChainage=NULL IF (@userType = 'H' and @hType is NULL) BEGIN SELECT ld.[BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)' , ld.[Direction],SSD.DateofInspection as 'Date of Inventory', LD.[SurveyYear] as 'Survey Year' , Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No' --,lkptSST.[Description] as [Type of superstructure],lkptSS.[Description] as [Structural system] --,lkptST.[Description] as [Deck Slab Material], ,hd.[PierNo] [Pier No], ft.[Description] as [Pier Foundation Type],lkptPT.[Description] as [Pier Type] , lkptAM.[Description] as [Pier Material],lkptABT.[Description] as [Bearing Type] FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode-- and (CASE WHEN ssd.SpanNo IS NOT NULL THEN SSD.SpanNo else hd.SpanNo END)=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL) BEGIN SELECT ld.[BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)' , ld.[Direction],SSD.DateofInspection as 'Date of Inventory', LD.[SurveyYear] as 'Survey Year' , Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No' --,lkptSST.[Description] as [Type of superstructure],lkptSS.[Description] as [Structural system] --,lkptST.[Description] as [Deck Slab Material], ,hd.[PierNo] [Pier No], ft.[Description] as [Pier Foundation Type],lkptPT.[Description] as [Pier Type] , lkptAM.[Description] as [Pier Material],lkptABT.[Description] as [Bearing Type] FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode-- and (CASE WHEN ssd.SpanNo IS NOT NULL THEN SSD.SpanNo else hd.SpanNo END)=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF (@userType = 'D' and @hType is NULL) BEGIN SELECT ld.[BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)' , ld.[Direction],SSD.DateofInspection as 'Date of Inventory', LD.[SurveyYear] as 'Survey Year' , Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No' --,lkptSST.[Description] as [Type of superstructure],lkptSS.[Description] as [Structural system] --,lkptST.[Description] as [Deck Slab Material], ,hd.[PierNo] [Pier No], ft.[Description] as [Pier Foundation Type],lkptPT.[Description] as [Pier Type] , lkptAM.[Description] as [Pier Material],lkptABT.[Description] as [Bearing Type] FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode-- and (CASE WHEN ssd.SpanNo IS NOT NULL THEN SSD.SpanNo else hd.SpanNo END)=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE BEGIN IF @hType = 'C' BEGIN SELECT ld.[BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)' , ld.[Direction],SSD.DateofInspection as 'Date of Inventory', LD.[SurveyYear] as 'Survey Year' , Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No' --,lkptSST.[Description] as [Type of superstructure],lkptSS.[Description] as [Structural system] --,lkptST.[Description] as [Deck Slab Material], ,hd.[PierNo] [Pier No], ft.[Description] as [Pier Foundation Type],lkptPT.[Description] as [Pier Type] , lkptAM.[Description] as [Pier Material],lkptABT.[Description] as [Bearing Type] FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode-- and (CASE WHEN ssd.SpanNo IS NOT NULL THEN SSD.SpanNo else hd.SpanNo END)=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle = @hTypeVal AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF @hType = 'D' BEGIN SELECT ld.[BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)' , ld.[Direction],SSD.DateofInspection as 'Date of Inventory', LD.[SurveyYear] as 'Survey Year' , Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No' --,lkptSST.[Description] as [Type of superstructure],lkptSS.[Description] as [Structural system] --,lkptST.[Description] as [Deck Slab Material], ,hd.[PierNo] [Pier No], ft.[Description] as [Pier Foundation Type],lkptPT.[Description] as [Pier Type] , lkptAM.[Description] as [Pier Material],lkptABT.[Description] as [Bearing Type] FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode-- and (CASE WHEN ssd.SpanNo IS NOT NULL THEN SSD.SpanNo else hd.SpanNo END)=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division = @hTypeVal AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF @hType = 'W' BEGIN SELECT ld.[BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)' , ld.[Direction],SSD.DateofInspection as 'Date of Inventory', LD.[SurveyYear] as 'Survey Year' , Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No' --,lkptSST.[Description] as [Type of superstructure],lkptSS.[Description] as [Structural system] --,lkptST.[Description] as [Deck Slab Material], ,hd.[PierNo] [Pier No], ft.[Description] as [Pier Foundation Type],lkptPT.[Description] as [Pier Type] , lkptAM.[Description] as [Pier Material],lkptABT.[Description] as [Bearing Type] FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode-- and (CASE WHEN ssd.SpanNo IS NOT NULL THEN SSD.SpanNo else hd.SpanNo END)=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF @hType = 'MLA' BEGIN SELECT ld.[BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)' , ld.[Direction],SSD.DateofInspection as 'Date of Inventory', LD.[SurveyYear] as 'Survey Year' , Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No' --,lkptSST.[Description] as [Type of superstructure],lkptSS.[Description] as [Structural system] --,lkptST.[Description] as [Deck Slab Material], ,hd.[PierNo] [Pier No], ft.[Description] as [Pier Foundation Type],lkptPT.[Description] as [Pier Type] , lkptAM.[Description] as [Pier Material],lkptABT.[Description] as [Bearing Type] FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode-- and (CASE WHEN ssd.SpanNo IS NOT NULL THEN SSD.SpanNo else hd.SpanNo END)=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode INNER JOIN NM.MLAConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MLACode = ISNULL(@hTypeVal, mcr.MLACode) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF @hType = 'MP' BEGIN SELECT ld.[BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)' , ld.[Direction],SSD.DateofInspection as 'Date of Inventory', LD.[SurveyYear] as 'Survey Year' , Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No' --,lkptSST.[Description] as [Type of superstructure],lkptSS.[Description] as [Structural system] --,lkptST.[Description] as [Deck Slab Material], ,hd.[PierNo] [Pier No], ft.[Description] as [Pier Foundation Type],lkptPT.[Description] as [Pier Type] , lkptAM.[Description] as [Pier Material],lkptABT.[Description] as [Bearing Type] FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode-- and (CASE WHEN ssd.SpanNo IS NOT NULL THEN SSD.SpanNo else hd.SpanNo END)=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode INNER JOIN NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal, mcr.MPCode) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END END end GO ALTER PROCEDURE [dbo].[GetspanInventoryByFilter] --EXEC [dbo].[GetWallConditionByFilter] 'NH030',null,'BR:NH030:0000.100',0,1000 --exec [dbo].[GetWallConditionByFilter] NULL,NULL,NULL,NULL,NULL,'krish', NULL,NULL,NULL --exec [dbo].[GetspanInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL --exec [dbo].[GetspanInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'pranusha', 'W',NULL,NULL --exec [dbo].[GetspanInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL --exec [dbo].[GetspanInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF(@userType = 'H' and @hType is NULL) Begin select BridgeCode AS 'Bridge Code' ,f.SurveyYear as 'Survey Year' ,SpanNo ,PierNo ,ft.[Description] as 'Foundation Type' ,WidthofRaft as 'Width of Raft' ,ThicknessofRaft as 'Thickness of Raft' ,LengthofRaft as 'Length of Raft' ,NoofWells as 'No of Wells' ,DiaofWell as 'Dia of Well' ,LengthofWell as 'Length of Well' ,f.Remarks from BMS.FoundationPierInventory f inner join BMS.LocationDetails ld on f.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=f.FoundationType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,P.SurveyYear as 'Survey Year ' --,SpanNo ,PierNo ,lkptPT.[Description] as 'Pier Type' ,lkptAM.[Description] as 'Pier Material' ,ClmnsThcktop as 'Thickness top(m)' ,ClmnsThckbttm as 'Thickness bottom(m)' ,PierTopLen as 'Length at top(m)' ,PierBttmLen as 'Length at bottom(m)' ,PierHeight as 'Height(m)' ,ClmnsCount as 'No of Columns' --,DiaOfColumnsM as 'Dia Of Columns(m)' --,SpacingofColumnsM as 'Spacing of Columns(m)' --,HeightofColumnM as 'Height of Column(m)' ,UniformCapHeight as 'Uniform height of cap(m)' ,CapWidth as 'Width of cap(m)' ,TaperedCapHeight as 'Tapered height of cap(m)' ,CapLenTop as 'Length of cap(m)' --,Cuteasewaterisprovided as 'Cut Easewater is provided' ,LKPTCWT.Description as 'Cut EaseWater Type' --,CutEaseWaterThicknessM as 'Cut EaseWater Thickness(m)' ,lkptABT.[Description] as 'Bearing Pier' ,BearingsCount as 'No Of Bearings' --,erthquakrestrindampnsprovd as 'erthquake restraint damper' ,P.Remarks , P.DateofInspection ,LKPTFT.Description AS FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,lkptAM.Description AS FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,LKPTSM.Description AS SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,LKPTWT.Description AS WellFundtionType ,CutEaseWaterType ,lkptABT.Description AS PierBearingsType from BMS.PierDetails p inner join BMS.LocationDetails ld on P.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON p.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON p.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =p.PierBearingsType LEFT OUTER JOIN [BMS].[LKPTCutWtrType] LKPTCWT ON LKPTCWT.CutWtrType=P.CutEaseWaterType LEFT OUTER JOIN [BMS].[LKPTSmcMtrl] LKPTSM ON LKPTSM.SmcMtrlType=P.SmcRstnrMtrl LEFT OUTER JOIN [BMS].[LKPTFoundType] LKPTFT ON LKPTFT.FoundType=P.FndtionType LEFT OUTER JOIN [BMS].[LKPTWellType] LKPTWT ON LKPTWT.WellType=P.WellFundtionType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage --,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,S.SurveyYear as 'Survey Year' ,SpanNo --,lkptSST.[Description] as 'Type of superstructure' --,lkptST.[Description] as 'Deck Slab Material' --,DeckSlabThicknessM as 'Deck Slab Thickness(m)' ,LongGirderCount as 'Longitudinal Girders Nos' ,LongGirderSpacing as 'Longitudinal Girders Spacing(m)' ,LongGirderDepth as 'Longitudinal Girders Depth(m)' ,LongGirderWidth as 'Longitudinal Girders Width(m)' ,CrossGirdersCount as 'Cross Girders Nos' ,MonolithicCrossGirder as 'Crsgirdmonolth kwtdkslb' ,ArchCountinSpan as 'Number of Arch in each Span' ,ArchSpace as 'Centre to Centre Spacing of Arch(m)' ,ArchSupportThickness as 'Arch Depth of spandrel at support(m)' ,ArchCrownThickness as 'Arch Depth of spandrel at Crown(m)' --,SteelMembersConnectionType as 'Steel Members Connection Type' --,DateofInventory --,Dimsteelmem as 'Dia of steel member' --,Material --,DeckslabtransversallyPrestressed as 'Deck slab transversally Prestressed' ,S.Remarks --,lkptSS.[Description] as 'Structural System' , SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,S.DateofInspection from BMS.SuperStructureDetails S inner join BMS.LocationDetails ld on S.BridgeCode = ld.BridgeID -- LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON S.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON S.StructuralSystem=lkptSS.StructSystemType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=S.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC END IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL) Begin select BridgeCode AS 'Bridge Code' ,f.SurveyYear as 'Survey Year' ,SpanNo ,PierNo ,ft.[Description] as 'Foundation Type' ,WidthofRaft as 'Width of Raft' ,ThicknessofRaft as 'Thickness of Raft' ,LengthofRaft as 'Length of Raft' ,NoofWells as 'No of Wells' ,DiaofWell as 'Dia of Well' ,LengthofWell as 'Length of Well' ,f.Remarks from BMS.FoundationPierInventory f inner join BMS.LocationDetails ld on f.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=f.FoundationType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,P.SurveyYear as 'Survey Year ' --,SpanNo ,PierNo ,lkptPT.[Description] as 'Pier Type' ,lkptAM.[Description] as 'Pier Material' ,ClmnsThcktop as 'Thickness top(m)' ,ClmnsThckbttm as 'Thickness bottom(m)' ,PierTopLen as 'Length at top(m)' ,PierBttmLen as 'Length at bottom(m)' ,PierHeight as 'Height(m)' ,ClmnsCount as 'No of Columns' --,DiaOfColumnsM as 'Dia Of Columns(m)' --,SpacingofColumnsM as 'Spacing of Columns(m)' --,HeightofColumnM as 'Height of Column(m)' ,UniformCapHeight as 'Uniform height of cap(m)' ,CapWidth as 'Width of cap(m)' ,TaperedCapHeight as 'Tapered height of cap(m)' ,CapLenTop as 'Length of cap(m)' --,Cuteasewaterisprovided as 'Cut Easewater is provided' ,CutEaseWaterType as 'Cut EaseWater Type' --,CutEaseWaterThicknessM as 'Cut EaseWater Thickness(m)' ,lkptABT.[Description] as 'Bearing Pier' ,BearingsCount as 'No Of Bearings' --,erthquakrestrindampnsprovd as 'erthquake restraint damper' ,P.Remarks ,P.DateofInspection ,LKPTFT.Description AS FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,lkptAM.Description AS FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,LKPTSM.Description AS SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,LKPTWT.Description AS WellFundtionType ,CutEaseWaterType ,lkptABT.Description AS PierBearingsType from BMS.PierDetails p inner join BMS.LocationDetails ld on P.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON p.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON p.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =p.PierBearingsType LEFT OUTER JOIN [BMS].[LKPTCutWtrType] LKPTCWT ON LKPTCWT.CutWtrType=P.CutEaseWaterType LEFT OUTER JOIN [BMS].[LKPTSmcMtrl] LKPTSM ON LKPTSM.SmcMtrlType=P.SmcRstnrMtrl LEFT OUTER JOIN [BMS].[LKPTFoundType] LKPTFT ON LKPTFT.FoundType=P.FndtionType LEFT OUTER JOIN [BMS].[LKPTWellType] LKPTWT ON LKPTWT.WellType=P.WellFundtionType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage --,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,S.SurveyYear as 'Survey Year' ,SpanNo --,lkptSST.[Description] as 'Type of superstructure' --,lkptST.[Description] as 'Deck Slab Material' --,DeckSlabThicknessM as 'Deck Slab Thickness(m)' ,LongGirderCount as 'Longitudinal Girders Nos' ,LongGirderSpacing as 'Longitudinal Girders Spacing(m)' ,LongGirderDepth as 'Longitudinal Girders Depth(m)' ,LongGirderWidth as 'Longitudinal Girders Width(m)' ,CrossGirdersCount as 'Cross Girders Nos' ,MonolithicCrossGirder as 'Crsgirdmonolth kwtdkslb' ,ArchCountinSpan as 'Number of Arch in each Span' ,ArchSpace as 'Centre to Centre Spacing of Arch(m)' ,ArchSupportThickness as 'Arch Depth of spandrel at support(m)' ,ArchCrownThickness as 'Arch Depth of spandrel at Crown(m)' --,SteelMembersConnectionType as 'Steel Members Connection Type' --,DateofInventory --,Dimsteelmem as 'Dia of steel member' --,Material --,DeckslabtransversallyPrestressed as 'Deck slab transversally Prestressed' ,S.Remarks --,lkptSS.[Description] as 'Structural System' , SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,S.DateofInspection from BMS.SuperStructureDetails S inner join BMS.LocationDetails ld on S.BridgeCode = ld.BridgeID -- LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON S.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON S.StructuralSystem=lkptSS.StructSystemType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=S.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC END ELSE IF (@userType = 'D' and @hType is NULL) Begin select BridgeCode AS 'Bridge Code' ,f.SurveyYear as 'Survey Year' ,SpanNo ,PierNo ,ft.[Description] as 'Foundation Type' ,WidthofRaft as 'Width of Raft' ,ThicknessofRaft as 'Thickness of Raft' ,LengthofRaft as 'Length of Raft' ,NoofWells as 'No of Wells' ,DiaofWell as 'Dia of Well' ,LengthofWell as 'Length of Well' ,f.Remarks from BMS.FoundationPierInventory f inner join BMS.LocationDetails ld on f.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=f.FoundationType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,P.SurveyYear as 'Survey Year ' --,SpanNo ,PierNo ,lkptPT.[Description] as 'Pier Type' ,lkptAM.[Description] as 'Pier Material' ,ClmnsThcktop as 'Thickness top(m)' ,ClmnsThckbttm as 'Thickness bottom(m)' ,PierTopLen as 'Length at top(m)' ,PierBttmLen as 'Length at bottom(m)' ,PierHeight as 'Height(m)' ,ClmnsCount as 'No of Columns' --,DiaOfColumnsM as 'Dia Of Columns(m)' --,SpacingofColumnsM as 'Spacing of Columns(m)' --,HeightofColumnM as 'Height of Column(m)' ,UniformCapHeight as 'Uniform height of cap(m)' ,CapWidth as 'Width of cap(m)' ,TaperedCapHeight as 'Tapered height of cap(m)' ,CapLenTop as 'Length of cap(m)' --,Cuteasewaterisprovided as 'Cut Easewater is provided' ,CutEaseWaterType as 'Cut EaseWater Type' --,CutEaseWaterThicknessM as 'Cut EaseWater Thickness(m)' ,lkptABT.[Description] as 'Bearing Pier' ,BearingsCount as 'No Of Bearings' --,erthquakrestrindampnsprovd as 'erthquake restraint damper' ,P.Remarks, P.DateofInspection ,LKPTFT.Description AS FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,lkptAM.Description AS FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,LKPTSM.Description AS SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,LKPTWT.Description AS WellFundtionType ,CutEaseWaterType ,lkptABT.Description AS PierBearingsType from BMS.PierDetails p inner join BMS.LocationDetails ld on P.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON p.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON p.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =p.PierBearingsType LEFT OUTER JOIN [BMS].[LKPTCutWtrType] LKPTCWT ON LKPTCWT.CutWtrType=P.CutEaseWaterType LEFT OUTER JOIN [BMS].[LKPTSmcMtrl] LKPTSM ON LKPTSM.SmcMtrlType=P.SmcRstnrMtrl LEFT OUTER JOIN [BMS].[LKPTFoundType] LKPTFT ON LKPTFT.FoundType=P.FndtionType LEFT OUTER JOIN [BMS].[LKPTWellType] LKPTWT ON LKPTWT.WellType=P.WellFundtionType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage --,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,S.SurveyYear as 'Survey Year' ,SpanNo --,lkptSST.[Description] as 'Type of superstructure' --,lkptST.[Description] as 'Deck Slab Material' --,DeckSlabThicknessM as 'Deck Slab Thickness(m)' ,LongGirderCount as 'Longitudinal Girders Nos' ,LongGirderSpacing as 'Longitudinal Girders Spacing(m)' ,LongGirderDepth as 'Longitudinal Girders Depth(m)' ,LongGirderWidth as 'Longitudinal Girders Width(m)' ,CrossGirdersCount as 'Cross Girders Nos' ,MonolithicCrossGirder as 'Crsgirdmonolth kwtdkslb' ,ArchCountinSpan as 'Number of Arch in each Span' ,ArchSpace as 'Centre to Centre Spacing of Arch(m)' ,ArchSupportThickness as 'Arch Depth of spandrel at support(m)' ,ArchCrownThickness as 'Arch Depth of spandrel at Crown(m)' --,SteelMembersConnectionType as 'Steel Members Connection Type' --,DateofInventory --,Dimsteelmem as 'Dia of steel member' --,Material --,DeckslabtransversallyPrestressed as 'Deck slab transversally Prestressed' ,S.Remarks --,lkptSS.[Description] as 'Structural System' , SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,S.DateofInspection from BMS.SuperStructureDetails S inner join BMS.LocationDetails ld on S.BridgeCode = ld.BridgeID -- LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON S.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON S.StructuralSystem=lkptSS.StructSystemType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=S.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC END ELSE IF (@hType = 'C' OR @hType = 'W') Begin select BridgeCode AS 'Bridge Code' ,f.SurveyYear as 'Survey Year' ,SpanNo ,PierNo ,ft.[Description] as 'Foundation Type' ,WidthofRaft as 'Width of Raft' ,ThicknessofRaft as 'Thickness of Raft' ,LengthofRaft as 'Length of Raft' ,NoofWells as 'No of Wells' ,DiaofWell as 'Dia of Well' ,LengthofWell as 'Length of Well' ,f.Remarks from BMS.FoundationPierInventory f inner join BMS.LocationDetails ld on f.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=f.FoundationType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle = @htypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,P.SurveyYear as 'Survey Year ' --,SpanNo ,PierNo ,lkptPT.[Description] as 'Pier Type' ,lkptAM.[Description] as 'Pier Material' ,ClmnsThcktop as 'Thickness top(m)' ,ClmnsThckbttm as 'Thickness bottom(m)' ,PierTopLen as 'Length at top(m)' ,PierBttmLen as 'Length at bottom(m)' ,PierHeight as 'Height(m)' ,ClmnsCount as 'No of Columns' --,DiaOfColumnsM as 'Dia Of Columns(m)' --,SpacingofColumnsM as 'Spacing of Columns(m)' --,HeightofColumnM as 'Height of Column(m)' ,UniformCapHeight as 'Uniform height of cap(m)' ,CapWidth as 'Width of cap(m)' ,TaperedCapHeight as 'Tapered height of cap(m)' ,CapLenTop as 'Length of cap(m)' --,Cuteasewaterisprovided as 'Cut Easewater is provided' ,CutEaseWaterType as 'Cut EaseWater Type' --,CutEaseWaterThicknessM as 'Cut EaseWater Thickness(m)' ,lkptABT.[Description] as 'Bearing Pier' ,BearingsCount as 'No Of Bearings' --,erthquakrestrindampnsprovd as 'erthquake restraint damper' ,P.Remarks , P.DateofInspection ,LKPTFT.Description AS FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,lkptAM.Description AS FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,LKPTSM.Description AS SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,LKPTWT.Description AS WellFundtionType ,CutEaseWaterType ,lkptABT.Description AS PierBearingsType from BMS.PierDetails p inner join BMS.LocationDetails ld on P.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON p.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON p.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =p.PierBearingsType LEFT OUTER JOIN [BMS].[LKPTCutWtrType] LKPTCWT ON LKPTCWT.CutWtrType=P.CutEaseWaterType LEFT OUTER JOIN [BMS].[LKPTSmcMtrl] LKPTSM ON LKPTSM.SmcMtrlType=P.SmcRstnrMtrl LEFT OUTER JOIN [BMS].[LKPTFoundType] LKPTFT ON LKPTFT.FoundType=P.FndtionType LEFT OUTER JOIN [BMS].[LKPTWellType] LKPTWT ON LKPTWT.WellType=P.WellFundtionType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle = @hTypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage --,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,S.SurveyYear as 'Survey Year' ,SpanNo --,lkptSST.[Description] as 'Type of superstructure' --,lkptST.[Description] as 'Deck Slab Material' --,DeckSlabThicknessM as 'Deck Slab Thickness(m)' ,LongGirderCount as 'Longitudinal Girders Nos' ,LongGirderSpacing as 'Longitudinal Girders Spacing(m)' ,LongGirderDepth as 'Longitudinal Girders Depth(m)' ,LongGirderWidth as 'Longitudinal Girders Width(m)' ,CrossGirdersCount as 'Cross Girders Nos' ,MonolithicCrossGirder as 'Crsgirdmonolth kwtdkslb' ,ArchCountinSpan as 'Number of Arch in each Span' ,ArchSpace as 'Centre to Centre Spacing of Arch(m)' ,ArchSupportThickness as 'Arch Depth of spandrel at support(m)' ,ArchCrownThickness as 'Arch Depth of spandrel at Crown(m)' --,SteelMembersConnectionType as 'Steel Members Connection Type' --,DateofInventory --,Dimsteelmem as 'Dia of steel member' --,Material --,DeckslabtransversallyPrestressed as 'Deck slab transversally Prestressed' ,S.Remarks --,lkptSS.[Description] as 'Structural System' , SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,S.DateofInspection from BMS.SuperStructureDetails S inner join BMS.LocationDetails ld on S.BridgeCode = ld.BridgeID -- LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON S.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON S.StructuralSystem=lkptSS.StructSystemType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=S.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle = @hTypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC END ELSE IF @hType = 'D' Begin select BridgeCode AS 'Bridge Code' ,f.SurveyYear as 'Survey Year' ,SpanNo ,PierNo ,ft.[Description] as 'Foundation Type' ,WidthofRaft as 'Width of Raft' ,ThicknessofRaft as 'Thickness of Raft' ,LengthofRaft as 'Length of Raft' ,NoofWells as 'No of Wells' ,DiaofWell as 'Dia of Well' ,LengthofWell as 'Length of Well' ,f.Remarks from BMS.FoundationPierInventory f inner join BMS.LocationDetails ld on f.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=f.FoundationType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division = @hTypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,P.SurveyYear as 'Survey Year ' --,SpanNo ,PierNo ,lkptPT.[Description] as 'Pier Type' ,lkptAM.[Description] as 'Pier Material' ,ClmnsThcktop as 'Thickness top(m)' ,ClmnsThckbttm as 'Thickness bottom(m)' ,PierTopLen as 'Length at top(m)' ,PierBttmLen as 'Length at bottom(m)' ,PierHeight as 'Height(m)' ,ClmnsCount as 'No of Columns' --,DiaOfColumnsM as 'Dia Of Columns(m)' --,SpacingofColumnsM as 'Spacing of Columns(m)' --,HeightofColumnM as 'Height of Column(m)' ,UniformCapHeight as 'Uniform height of cap(m)' ,CapWidth as 'Width of cap(m)' ,TaperedCapHeight as 'Tapered height of cap(m)' ,CapLenTop as 'Length of cap(m)' --,Cuteasewaterisprovided as 'Cut Easewater is provided' ,CutEaseWaterType as 'Cut EaseWater Type' --,CutEaseWaterThicknessM as 'Cut EaseWater Thickness(m)' ,lkptABT.[Description] as 'Bearing Pier' ,BearingsCount as 'No Of Bearings' --,erthquakrestrindampnsprovd as 'erthquake restraint damper' ,P.Remarks, P.DateofInspection ,LKPTFT.Description AS FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,lkptAM.Description AS FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,LKPTSM.Description AS SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,LKPTWT.Description AS WellFundtionType ,CutEaseWaterType ,lkptABT.Description AS PierBearingsType from BMS.PierDetails p inner join BMS.LocationDetails ld on P.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON p.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON p.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =p.PierBearingsType LEFT OUTER JOIN [BMS].[LKPTCutWtrType] LKPTCWT ON LKPTCWT.CutWtrType=P.CutEaseWaterType LEFT OUTER JOIN [BMS].[LKPTSmcMtrl] LKPTSM ON LKPTSM.SmcMtrlType=P.SmcRstnrMtrl LEFT OUTER JOIN [BMS].[LKPTFoundType] LKPTFT ON LKPTFT.FoundType=P.FndtionType LEFT OUTER JOIN [BMS].[LKPTWellType] LKPTWT ON LKPTWT.WellType=P.WellFundtionType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division = @hTypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage --,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,S.SurveyYear as 'Survey Year' ,SpanNo --,lkptSST.[Description] as 'Type of superstructure' --,lkptST.[Description] as 'Deck Slab Material' --,DeckSlabThicknessM as 'Deck Slab Thickness(m)' ,LongGirderCount as 'Longitudinal Girders Nos' ,LongGirderSpacing as 'Longitudinal Girders Spacing(m)' ,LongGirderDepth as 'Longitudinal Girders Depth(m)' ,LongGirderWidth as 'Longitudinal Girders Width(m)' ,CrossGirdersCount as 'Cross Girders Nos' ,MonolithicCrossGirder as 'Crsgirdmonolth kwtdkslb' ,ArchCountinSpan as 'Number of Arch in each Span' ,ArchSpace as 'Centre to Centre Spacing of Arch(m)' ,ArchSupportThickness as 'Arch Depth of spandrel at support(m)' ,ArchCrownThickness as 'Arch Depth of spandrel at Crown(m)' --,SteelMembersConnectionType as 'Steel Members Connection Type' --,DateofInventory --,Dimsteelmem as 'Dia of steel member' --,Material --,DeckslabtransversallyPrestressed as 'Deck slab transversally Prestressed' ,S.Remarks --,lkptSS.[Description] as 'Structural System' , SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,S.DateofInspection from BMS.SuperStructureDetails S inner join BMS.LocationDetails ld on S.BridgeCode = ld.BridgeID -- LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON S.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON S.StructuralSystem=lkptSS.StructSystemType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=S.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division = @hTypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC END ELSE IF @hType = 'MLA' Begin select BridgeCode AS 'Bridge Code' ,f.SurveyYear as 'Survey Year' ,SpanNo ,PierNo ,ft.[Description] as 'Foundation Type' ,WidthofRaft as 'Width of Raft' ,ThicknessofRaft as 'Thickness of Raft' ,LengthofRaft as 'Length of Raft' ,NoofWells as 'No of Wells' ,DiaofWell as 'Dia of Well' ,LengthofWell as 'Length of Well' ,f.Remarks from BMS.FoundationPierInventory f inner join BMS.LocationDetails ld on f.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=f.FoundationType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode inner join NM.MLAConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MLACode = ISNULL(@hTypeVal,mcr.MLACode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' -- ,P.SurveyYear as 'Survey Year ' --,SpanNo ,PierNo ,lkptPT.[Description] as 'Pier Type' ,lkptAM.[Description] as 'Pier Material' ,ClmnsThcktop as 'Thickness top(m)' ,ClmnsThckbttm as 'Thickness bottom(m)' ,PierTopLen as 'Length at top(m)' ,PierBttmLen as 'Length at bottom(m)' ,PierHeight as 'Height(m)' ,ClmnsCount as 'No of Columns' --,DiaOfColumnsM as 'Dia Of Columns(m)' --,SpacingofColumnsM as 'Spacing of Columns(m)' --,HeightofColumnM as 'Height of Column(m)' ,UniformCapHeight as 'Uniform height of cap(m)' ,CapWidth as 'Width of cap(m)' ,TaperedCapHeight as 'Tapered height of cap(m)' ,CapLenTop as 'Length of cap(m)' --,Cuteasewaterisprovided as 'Cut Easewater is provided' ,CutEaseWaterType as 'Cut EaseWater Type' --,CutEaseWaterThicknessM as 'Cut EaseWater Thickness(m)' ,lkptABT.[Description] as 'Bearing Pier' ,BearingsCount as 'No Of Bearings' --,erthquakrestrindampnsprovd as 'erthquake restraint damper' ,P.Remarks , P.DateofInspection ,LKPTFT.Description AS FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,lkptAM.Description AS FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,LKPTSM.Description AS SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,LKPTWT.Description AS WellFundtionType ,CutEaseWaterType ,lkptABT.Description AS PierBearingsType from BMS.PierDetails p inner join BMS.LocationDetails ld on P.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON p.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON p.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =p.PierBearingsType LEFT OUTER JOIN [BMS].[LKPTCutWtrType] LKPTCWT ON LKPTCWT.CutWtrType=P.CutEaseWaterType LEFT OUTER JOIN [BMS].[LKPTSmcMtrl] LKPTSM ON LKPTSM.SmcMtrlType=P.SmcRstnrMtrl LEFT OUTER JOIN [BMS].[LKPTFoundType] LKPTFT ON LKPTFT.FoundType=P.FndtionType LEFT OUTER JOIN [BMS].[LKPTWellType] LKPTWT ON LKPTWT.WellType=P.WellFundtionType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode inner join NM.MLAConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MLACode = ISNULL(@hTypeVal,mcr.MLACode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage --,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,S.SurveyYear as 'Survey Year' ,SpanNo --,lkptSST.[Description] as 'Type of superstructure' --,lkptST.[Description] as 'Deck Slab Material' --,DeckSlabThicknessM as 'Deck Slab Thickness(m)' ,LongGirderCount as 'Longitudinal Girders Nos' ,LongGirderSpacing as 'Longitudinal Girders Spacing(m)' ,LongGirderDepth as 'Longitudinal Girders Depth(m)' ,LongGirderWidth as 'Longitudinal Girders Width(m)' ,CrossGirdersCount as 'Cross Girders Nos' ,MonolithicCrossGirder as 'Crsgirdmonolth kwtdkslb' ,ArchCountinSpan as 'Number of Arch in each Span' ,ArchSpace as 'Centre to Centre Spacing of Arch(m)' ,ArchSupportThickness as 'Arch Depth of spandrel at support(m)' ,ArchCrownThickness as 'Arch Depth of spandrel at Crown(m)' --,SteelMembersConnectionType as 'Steel Members Connection Type' --,DateofInventory --,Dimsteelmem as 'Dia of steel member' --,Material --,DeckslabtransversallyPrestressed as 'Deck slab transversally Prestressed' ,S.Remarks --,lkptSS.[Description] as 'Structural System' , SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,S.DateofInspection from BMS.SuperStructureDetails S inner join BMS.LocationDetails ld on S.BridgeCode = ld.BridgeID -- LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON S.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON S.StructuralSystem=lkptSS.StructSystemType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=S.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode inner join NM.MLAConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,Ld.RoadCode) AND mcr.MLACode = ISNULL(@hTypeVal,mcr.MLACode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC END ELSE IF @hType = 'MP' Begin select BridgeCode AS 'Bridge Code' ,f.SurveyYear as 'Survey Year' ,SpanNo ,PierNo ,ft.[Description] as 'Foundation Type' ,WidthofRaft as 'Width of Raft' ,ThicknessofRaft as 'Thickness of Raft' ,LengthofRaft as 'Length of Raft' ,NoofWells as 'No of Wells' ,DiaofWell as 'Dia of Well' ,LengthofWell as 'Length of Well' ,f.Remarks from BMS.FoundationPierInventory f inner join BMS.LocationDetails ld on f.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=f.FoundationType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,P.SurveyYear as 'Survey Year ' --,SpanNo ,PierNo ,lkptPT.[Description] as 'Pier Type' ,lkptAM.[Description] as 'Pier Material' ,ClmnsThcktop as 'Thickness top(m)' ,ClmnsThckbttm as 'Thickness bottom(m)' ,PierTopLen as 'Length at top(m)' ,PierBttmLen as 'Length at bottom(m)' ,PierHeight as 'Height(m)' ,ClmnsCount as 'No of Columns' --,DiaOfColumnsM as 'Dia Of Columns(m)' --,SpacingofColumnsM as 'Spacing of Columns(m)' --,HeightofColumnM as 'Height of Column(m)' ,UniformCapHeight as 'Uniform height of cap(m)' ,CapWidth as 'Width of cap(m)' ,TaperedCapHeight as 'Tapered height of cap(m)' ,CapLenTop as 'Length of cap(m)' --,Cuteasewaterisprovided as 'Cut Easewater is provided' ,CutEaseWaterType as 'Cut EaseWater Type' --,CutEaseWaterThicknessM as 'Cut EaseWater Thickness(m)' ,lkptABT.[Description] as 'Bearing Pier' ,BearingsCount as 'No Of Bearings' --,erthquakrestrindampnsprovd as 'erthquake restraint damper' ,P.Remarks, P.DateofInspection ,LKPTFT.Description AS FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,lkptAM.Description AS FndtionMtrlType ,CapLenBttm ,BearingsPrvd ,BearingsVisible ,SmcRstnrPrvd ,LKPTSM.Description AS SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,LKPTWT.Description AS WellFundtionType ,CutEaseWaterType ,lkptABT.Description AS PierBearingsType from BMS.PierDetails p inner join BMS.LocationDetails ld on P.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON p.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON p.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =p.PierBearingsType LEFT OUTER JOIN [BMS].[LKPTCutWtrType] LKPTCWT ON LKPTCWT.CutWtrType=P.CutEaseWaterType LEFT OUTER JOIN [BMS].[LKPTSmcMtrl] LKPTSM ON LKPTSM.SmcMtrlType=P.SmcRstnrMtrl LEFT OUTER JOIN [BMS].[LKPTFoundType] LKPTFT ON LKPTFT.FoundType=P.FndtionType LEFT OUTER JOIN [BMS].[LKPTWellType] LKPTWT ON LKPTWT.WellType=P.WellFundtionType INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage --,convert(int, [SpanNo]) ASC select BridgeCode as 'Bridge Code' --,S.SurveyYear as 'Survey Year' ,SpanNo --,lkptSST.[Description] as 'Type of superstructure' --,lkptST.[Description] as 'Deck Slab Material' --,DeckSlabThicknessM as 'Deck Slab Thickness(m)' ,LongGirderCount as 'Longitudinal Girders Nos' ,LongGirderSpacing as 'Longitudinal Girders Spacing(m)' ,LongGirderDepth as 'Longitudinal Girders Depth(m)' ,LongGirderWidth as 'Longitudinal Girders Width(m)' ,CrossGirdersCount as 'Cross Girders Nos' ,MonolithicCrossGirder as 'Crsgirdmonolth kwtdkslb' ,ArchCountinSpan as 'Number of Arch in each Span' ,ArchSpace as 'Centre to Centre Spacing of Arch(m)' ,ArchSupportThickness as 'Arch Depth of spandrel at support(m)' ,ArchCrownThickness as 'Arch Depth of spandrel at Crown(m)' --,SteelMembersConnectionType as 'Steel Members Connection Type' --,DateofInventory --,Dimsteelmem as 'Dia of steel member' --,Material --,DeckslabtransversallyPrestressed as 'Deck slab transversally Prestressed' ,S.Remarks --,lkptSS.[Description] as 'Structural System' , SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth ,S.DateofInspection from BMS.SuperStructureDetails S inner join BMS.LocationDetails ld on S.BridgeCode = ld.BridgeID -- LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON S.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON S.StructuralSystem=lkptSS.StructSystemType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=S.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,Ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage ,convert(int, [SpanNo]) ASC END END GO ALTER PROCEDURE [dbo].[GetFoundationPierInventoryByFilter] --EXEC [dbo].[GetFoundationPierInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'pranushan', 'W',NULL,NULL --EXEC [dbo].[GetFoundationPierInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL --EXEC [dbo].[GetFoundationPierInventoryByFilter] 'MDR_PND01_002',NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL --EXEC [dbo].[GetFoundationPierInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL --EXEC [dbo].[GetFoundationPierInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF(@userType = 'H') Begin if @bridgeType='' set @bridgeType=NULL if @bridgeCode='' set @bridgeCode=NULL if @StartChainage='' set @StartChainage=NULL if @EndChainage='' set @EndChainage=NULL SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ssd.DateofInspection, [BrdgFoundPierInvid], hd.[BridgeCode], Case When HD.[SurveyYear] IS NOT NULL THEN HD.[SurveyYear] ELSE hd.[SurveyYear] END 'SurveyYear', Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No', hd.[PierNo], [FoundationType], [WidthofRaft], [ThicknessofRaft], [LengthofRaft], [NoofWells], [DiaofWell], [LengthofWell], HD.[Remarks],ft.Description FoundationTypeDescription, --lkptSST.Description as Typeofsuperstructure, --lkptSS.Description as Structuralsystem, --lkptST.Description as DeckSlab,-- SSD.DeckSlab, lkptPT.Description as PierType, lkptAM.Description as PierMaterial, lkptABT.Description as BearingType,Chainage,HYd.DateofInventory ,CASE WHEN (hd.[BridgeCode] IS NOT NULL OR PD.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END 'ApprovalStatus' , LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode -- and hd.SpanNo=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) ORDER BY lm.IsPilot desc, ld.RoadCode,ld.Chainage, Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL) BEGIN if @bridgeType='' set @bridgeType=NULL if @bridgeCode='' set @bridgeCode=NULL if @StartChainage='' set @StartChainage=NULL if @EndChainage='' set @EndChainage=NULL SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ssd.DateofInspection, [BrdgFoundPierInvid], hd.[BridgeCode], Case When HD.[SurveyYear] IS NOT NULL THEN HD.[SurveyYear] ELSE hd.[SurveyYear] END 'SurveyYear', Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No', hd.[PierNo], [FoundationType] , [WidthofRaft], [ThicknessofRaft], [LengthofRaft], [NoofWells], [DiaofWell], [LengthofWell], HD.[Remarks],ft.Description FoundationTypeDescription, --lkptSST.Description as Typeofsuperstructure, --lkptSS.Description as Structuralsystem, --lkptST.Description as DeckSlab,-- SSD.DeckSlab, lkptPT.Description as PierType, lkptAM.Description as PierMaterial, lkptABT.Description as BearingType,Chainage,HYd.DateofInventory ,CASE WHEN (hd.[BridgeCode] IS NOT NULL OR PD.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END 'ApprovalStatus' , LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode --and hd.SpanNo=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) ORDER BY lm.IsPilot desc, ld.RoadCode,ld.Chainage, Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF (@userType = 'D' and @hType is NULL) BEGIN if @bridgeType='' set @bridgeType=NULL if @bridgeCode='' set @bridgeCode=NULL if @StartChainage='' set @StartChainage=NULL if @EndChainage='' set @EndChainage=NULL SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ssd.DateofInspection, [BrdgFoundPierInvid], hd.[BridgeCode], Case When HD.[SurveyYear] IS NOT NULL THEN HD.[SurveyYear] ELSE hd.[SurveyYear] END 'SurveyYear', Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No', hd.[PierNo], [FoundationType], [WidthofRaft], [ThicknessofRaft], [LengthofRaft], [NoofWells], [DiaofWell], [LengthofWell], HD.[Remarks],ft.Description FoundationTypeDescription, --lkptSST.Description as Typeofsuperstructure, --lkptSS.Description as Structuralsystem, --lkptST.Description as DeckSlab,-- SSD.DeckSlab, lkptPT.Description as PierType, lkptAM.Description as PierMaterial, lkptABT.Description as BearingType,Chainage,HYd.DateofInventory ,CASE WHEN (hd.[BridgeCode] IS NOT NULL OR PD.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END 'ApprovalStatus' , LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth FROM [BMS].[LocationDetails] ld Left OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode --and hd.SpanNo=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) ORDER BY lm.IsPilot desc, ld.RoadCode,ld.Chainage, Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF @hType = 'C' BEGIN if @bridgeType='' set @bridgeType=NULL if @bridgeCode='' set @bridgeCode=NULL if @StartChainage='' set @StartChainage=NULL if @EndChainage='' set @EndChainage=NULL SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ssd.DateofInspection, [BrdgFoundPierInvid], hd.[BridgeCode], Case When HD.[SurveyYear] IS NOT NULL THEN HD.[SurveyYear] ELSE hd.[SurveyYear] END 'SurveyYear', Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No', hd.[PierNo], [FoundationType], [WidthofRaft], [ThicknessofRaft], [LengthofRaft], [NoofWells], [DiaofWell], [LengthofWell], HD.[Remarks],ft.[Description] FoundationTypeDescription, -- lkptSST.Description as Typeofsuperstructure, -- lkptSS.Description as Structuralsystem, --lkptST.Description as DeckSlab,-- SSD.DeckSlab, lkptPT.Description as PierType, lkptAM.Description as PierMaterial, lkptABT.Description as BearingType,Chainage,HYd.DateofInventory ,CASE WHEN (hd.[BridgeCode] IS NOT NULL OR PD.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END 'ApprovalStatus' , LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode --and hd.SpanNo=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle = @hTypeVal AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) ORDER BY lm.IsPilot desc, ld.RoadCode,ld.Chainage, Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF @hType = 'D' BEGIN if @bridgeType='' set @bridgeType=NULL if @bridgeCode='' set @bridgeCode=NULL if @StartChainage='' set @StartChainage=NULL if @EndChainage='' set @EndChainage=NULL SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ssd.DateofInspection, [BrdgFoundPierInvid], hd.[BridgeCode], Case When HD.[SurveyYear] IS NOT NULL THEN HD.[SurveyYear] ELSE hd.[SurveyYear] END 'SurveyYear', Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No', hd.[PierNo], [FoundationType], [WidthofRaft], [ThicknessofRaft], [LengthofRaft], [NoofWells], [DiaofWell], [LengthofWell], HD.[Remarks],ft.Description FoundationTypeDescription, --lkptSST.Description as Typeofsuperstructure, --lkptSS.Description as Structuralsystem, --lkptST.Description as DeckSlab,-- SSD.DeckSlab, lkptPT.Description as PierType, lkptAM.Description as PierMaterial, lkptABT.Description as BearingType,Chainage,HYd.DateofInventory ,CASE WHEN (hd.[BridgeCode] IS NOT NULL OR PD.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END 'ApprovalStatus' , LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode -- and hd.SpanNo=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division = @hTypeVal AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID) ORDER BY lm.IsPilot desc, ld.RoadCode,ld.Chainage, Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF @hType = 'W' BEGIN if @bridgeType='' set @bridgeType=NULL if @bridgeCode='' set @bridgeCode=NULL if @StartChainage='' set @StartChainage=NULL if @EndChainage='' set @EndChainage=NULL SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ssd.DateofInspection, [BrdgFoundPierInvid], hd.[BridgeCode], Case When HD.[SurveyYear] IS NOT NULL THEN HD.[SurveyYear] ELSE hd.[SurveyYear] END 'SurveyYear', Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No', hd.[PierNo], [FoundationType], [WidthofRaft], [ThicknessofRaft], [LengthofRaft], [NoofWells], [DiaofWell], [LengthofWell], HD.[Remarks],ft.Description FoundationTypeDescription, --lkptSST.Description as Typeofsuperstructure, --lkptSS.Description as Structuralsystem, --lkptST.Description as DeckSlab,-- SSD.DeckSlab, lkptPT.Description as PierType, lkptAM.Description as PierMaterial, lkptABT.Description as BearingType,Chainage,HYd.DateofInventory ,CASE WHEN (hd.[BridgeCode] IS NOT NULL OR PD.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END 'ApprovalStatus' , LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth FROM [BMS].[LocationDetails] ld RIGHT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode --and hd.SpanNo=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) /* Commented on 11/26/2020*/ AND lm.Circle IN (SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) ORDER BY lm.IsPilot desc, ld.RoadCode,ld.Chainage, Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF @hType = 'MLA' BEGIN if @bridgeType='' set @bridgeType=NULL if @bridgeCode='' set @bridgeCode=NULL if @StartChainage='' set @StartChainage=NULL if @EndChainage='' set @EndChainage=NULL SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ssd.DateofInspection, [BrdgFoundPierInvid], hd.[BridgeCode], Case When HD.[SurveyYear] IS NOT NULL THEN HD.[SurveyYear] ELSE hd.[SurveyYear] END 'SurveyYear', Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No', hd.[PierNo], [FoundationType], [WidthofRaft], [ThicknessofRaft], [LengthofRaft], [NoofWells], [DiaofWell], [LengthofWell], HD.[Remarks],ft.Description FoundationTypeDescription, --lkptSST.Description as Typeofsuperstructure, --lkptSS.Description as Structuralsystem, --lkptST.Description as DeckSlab,-- SSD.DeckSlab, lkptPT.Description as PierType, lkptAM.Description as PierMaterial, lkptABT.Description as BearingType,Chainage,HYd.DateofInventory ,CASE WHEN (hd.[BridgeCode] IS NOT NULL OR PD.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END 'ApprovalStatus' , LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode -- and hd.SpanNo=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) ORDER BY lm.IsPilot desc, ld.RoadCode,ld.Chainage, Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END ELSE IF @hType = 'MP' BEGIN if @bridgeType='' set @bridgeType=NULL if @bridgeCode='' set @bridgeCode=NULL if @StartChainage='' set @StartChainage=NULL if @EndChainage='' set @EndChainage=NULL SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],ssd.DateofInspection, [BrdgFoundPierInvid], hd.[BridgeCode], Case When HD.[SurveyYear] IS NOT NULL THEN HD.[SurveyYear] ELSE hd.[SurveyYear] END 'SurveyYear', Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END 'Span No', hd.[PierNo], [FoundationType], [WidthofRaft], [ThicknessofRaft], [LengthofRaft], [NoofWells], [DiaofWell], [LengthofWell], HD.[Remarks],ft.Description FoundationTypeDescription, --lkptSST.Description as Typeofsuperstructure, --lkptSS.Description as Structuralsystem, --lkptST.Description as DeckSlab,-- SSD.DeckSlab, lkptPT.Description as PierType, lkptAM.Description as PierMaterial, lkptABT.Description as BearingType,Chainage,HYd.DateofInventory ,CASE WHEN (hd.[BridgeCode] IS NOT NULL OR PD.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END 'ApprovalStatus' , LongGirderCount ,LongGirderSpacing ,LongGirderDepth ,LongGirderWidth ,CrossGirdersCount ,MonolithicCrossGirder ,ArchCountinSpan ,ArchSpace ,ArchSupportThickness ,ArchCrownThickness ,SpanLen ,SpanTopWidth ,SpanBttmWidth ,SpanThickness ,CrossGirderDepth ,CrossGirderThick ,MainSpanLen ,CantileverSpanLen ,SuspendedSpanLen ,PylonCableCount ,ArchDepth FROM [BMS].[LocationDetails] ld LEFT OUTER JOIN BMS.SuperStructureDetails SSD ON ld.BridgeID=SSD.BridgeCode LEFT OUTER JOIN [BMS].[FoundationPierInventory] hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = SSD.SpanNo LEFT OUTER JOIN BMS.LKPTFoundType ft ON ft.FoundType=hd.FoundationType LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode LEFT OUTER JOIN BMS.PierDetails PD ON ld.BridgeID=PD.BridgeCode -- and hd.SpanNo=PD.SpanNo --LEFT OUTER JOIN BMS.LKPTSupStructType lkptSST ON SSD.Typeofsuperstructure=lkptSST.SupStructType --LEFT OUTER JOIN BMS.LKPTStructSystem lkptSS ON SSD.StructuralSystem=lkptSS.StructSystemType LEFT OUTER JOIN BMS.LKPTPierType lkptPT ON PD.PierType=lkptPT.LKPTPierType LEFT OUTER JOIN BMS.LKPTAbutMaterial lkptAM ON PD.PierMaterial=lkptAM.AbutMaterialType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =PD.PierBearingsType --LEFT OUTER JOIN BMS.[LKPTSlabType] lkptST ON lkptST.Slabtype=SSD.DeckSlab INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND ld.BridgeID = ISNULL(@bridgeCode,ld.BridgeID) ORDER BY lm.IsPilot desc, ld.RoadCode,ld.Chainage, Convert(int,Case When SSD.[SpanNo] IS NOT NULL THEN SSD.[SpanNo] ELSE hd.[SpanNo] END) ASC END END GO ALTER PROCEDURE [BMS].[BCISummary] @SurveyYear NVARCHAR(5), @SearchType NVARCHAR(5), @SearchVal NVARCHAR (50) =NULL, @User NVARCHAR(100) =NULL, @CName NVARCHAR(100) = NULL, @DName NVARCHAR(100) = NULL, @SubDivision NVARCHAR(100) = NULL, @BridgeCode NVARCHAR(100) = NULL AS BEGIN declare @userType varchar(20) select @userType = CASE WHEN areatype = 'H' THEN 'HQ' ELSE areatype END from SSUM.[User] where [UserName] =@user --IF @Circle IS NULL AND @Division IS NULL AND @SubDivision IS NULL AND @MLAConstituency IS NULL AND @MPConstituency IS NULL IF (@SearchType = 'C' ) BEGIN IF (@searchVal IS NULL or UPPER(@SearchVal) = 'NULL' ) BEGIN If (@userType = 'HQ' ) begin SELECT 'Circle'as SEL,C.CirclesName AS 'Name', rm.RoadCategoryCode,rm.[Name] AS 'RoadName', LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required ,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1 -- and B.ProcessedYear=SD.SurveyYear left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) Order by C.CirclesName,LD.RoadCode,B.BridgeCode end else If (@userType = 'D' ) begin SELECT 'Circle'as SEL,C.CirclesName AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.Division D ON lm.Division=D.DivisionCode INNER JOIN NM.Circle C ON D.CircleCode=C.CircleCode WHERE D.DivisionCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) Order by C.CirclesName,LD.RoadCode,B.BridgeCode end else begin SELECT 'Circle'as SEL,C.CirclesName AS 'Name', rm.RoadCategoryCode,rm.[Name] AS 'RoadName', LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode WHERE C.CircleCode in (SELECT areaname FROM SSUM.userareas WHERE username =@user) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) end END else If (@userType = 'D' ) begin SELECT 'Circle'as SEL,C.CirclesName AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.Division D ON lm.Division=D.DivisionCode INNER JOIN NM.Circle C ON D.CircleCode=C.CircleCode WHERE D.DivisionCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND C.CircleCode = @SearchVal AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) Order by C.CirclesName,LD.RoadCode,B.BridgeCode end ELSE BEGIN SELECT 'Circle'as SEL,C.CirclesName AS 'Name', rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode WHERE C.CircleCode = @SearchVal AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) END END ELSE IF (@SearchType = 'D' ) BEGIN IF (@searchVal IS NULL or UPPER(@SearchVal) = 'NULL' ) BEGIN If (@userType = 'HQ' ) begin SELECT 'Division'AS SEL,D.DivisionName AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.Division D ON lm.Division=D.DivisionCode INNER JOIN NM.Circle C ON D.CircleCode=C.CircleCode WHERE C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionName = ISNULL(@DName, D.DivisionName) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) end else if(@userType in ('C','W')) begin SELECT 'Division'AS SEL,D.DivisionName AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear and SD.SpanNo=1 left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.Division D ON lm.Division=D.DivisionCode INNER JOIN NM.Circle C ON D.CircleCode=C.CircleCode WHERE C.CirclesName = IsNULL(@CName,C.CirclesName) and C.CircleCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) end else begin SELECT 'Division'AS SEL,D.DivisionName AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear and SD.SpanNo=1 left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.Division D ON lm.Division=D.DivisionCode INNER JOIN NM.Circle C ON D.CircleCode=C.CircleCode WHERE C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) end END ELSE BEGIN SELECT 'Division'AS SEL,D.DivisionName AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear and SD.SpanNo=1 left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.Division D ON lm.Division=D.DivisionCode INNER JOIN NM.Circle C ON D.CircleCode=C.CircleCode WHERE C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionCode = @SearchVal AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) END END ELSE IF (@SearchType = 'S' ) BEGIN IF (@searchVal IS NULL or UPPER(@SearchVal) = 'NULL' ) BEGIN If (@userType = 'HQ' ) begin SELECT 'Sub Division'AS SEL,SDV.SubDivisionName AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear and SD.SpanNo=1 left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.SubDivision SDV ON lm.SubDivision=SDV.SubDivisionCode INNER JOIN NM.Division D ON SDV.DivisionCode=D.DivisionCode INNER JOIN NM.Circle C ON D.CircleCode=C.CircleCode WHERE C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionName = ISNULL(@DName, D.DivisionName) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) end else if(@userType in ('C','W')) begin SELECT 'Sub Division'AS SEL,SDV.SubDivisionName AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear and SD.SpanNo=1 left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.SubDivision SDV ON lm.SubDivision= SDV.SubDivisionCode INNER JOIN NM.Division D ON SDV.DivisionCode=D.DivisionCode INNER JOIN NM.Circle C ON D.CircleCode=C.CircleCode WHERE C.CircleCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionName = ISNULL(@DName, D.DivisionName) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) end else if(@userType='D') begin SELECT 'Sub Division'AS SEL,SDV.SubDivisionName AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear and SD.SpanNo=1 left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.SubDivision SDV ON lm.SubDivision=SDV.SubDivisionCode INNER JOIN NM.Division D ON SDV.DivisionCode=D.DivisionCode INNER JOIN NM.Circle C ON D.CircleCode=C.CircleCode WHERE D.DivisionCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionName = ISNULL(@DName, D.DivisionName) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) end else begin SELECT 'Sub Division'AS SEL,SDV.SubDivisionName AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear and SD.SpanNo=1 left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.SubDivision SDV ON lm.SubDivision=SDV.SubDivisionCode INNER JOIN NM.Division D ON SDV.DivisionCode=D.DivisionCode INNER JOIN NM.Circle C ON D.CircleCode=C.CircleCode WHERE SDV.SubDivisionCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionName = ISNULL(@DName, D.DivisionName) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) end END ELSE BEGIN SELECT 'Sub Division'AS SEL,SDV.SubDivisionName AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear and SD.SpanNo=1 left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.SubDivision SDV ON lm.SubDivision=SDV.SubDivisionCode INNER JOIN NM.Division D ON SDV.DivisionCode=D.DivisionCode INNER JOIN NM.Circle C ON D.CircleCode=C.CircleCode WHERE SDV.SubDivisionCode = @SearchVal AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) END END ELSE IF (@SearchType = 'MP' ) BEGIN SELECT 'MP Constituency'AS SEL, MPC.Name AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear and SD.SpanNo=1 left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.MPConstituencyRoad MPr ON MPr.RoadCode = rm.RoadCode AND LD.Chainage>=MPR.StartChainage And LD.Chainage<=MPR.EndChainage --AND CI.EndChainage>=MPR.StartChainage And CI.EndChainage<=MPR.EndChainage INNER JOIN NM.MPConstituency MPc ON MPc.MpcId = MPr.MPCode WHERE MPC.MpcId= ISNULL ( @searchval , MPC.MpcId ) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) END ELSE IF (@SearchType = 'ML' ) BEGIN SELECT 'MLA Constituency'AS SEL, MPC.Name AS 'Name',rm.RoadCategoryCode,rm.[Name] AS 'RoadName',LD.RoadCode,LD.LinkCode,B.BridgeCode,BT.[Description] as'BridgeType',LD.YearofConstruction ,BD.Type1SpanNo,--ST.[Description] as 'SuperStructureType', BC.[Description] as 'BridgeCategory' ,B.BCI,(Case when B.Widening_Required='Widening not required' then 'No' Else 'Yes' End) as Widening_Required,B.RepairCost,prrty as [Priority],B.maint_Brdg as [Maintenance Bridge] from BMS.BCI B inner join BMS.LocationDetails LD on B.BridgeCode=LD.BridgeID and B.ProcessedYear=LD.SurveyYear left join BMS.BridgeDetails BD on B.BridgeCode=BD.BridgeCode and B.ProcessedYear=BD.SurveyYear left join BMS.SuperStructureDetails SD on B.BridgeCode=SD.BridgeCode and SD.SpanNo=1--and B.ProcessedYear=SD.SurveyYear and SD.SpanNo=1 left join BMS.HydraulicDetails HD on B.BridgeCode=HD.BridgeCode and B.ProcessedYear=HD.SurveyYear --left join BMS.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType left join BMS.LKPTBridgeType BT on LD.TypeoftheBridge=BT.BridgeType left join BMS.LKPTBrdgCatg BC on HD.BridgeCategory=BC.BrdgCatgType INNER JOIN NM.roadmaster rm ON B.RoadCode = rm.roadcode INNER JOIN NM.MLAConstituencyRoad MPr ON MPr.RoadCode = rm.RoadCode AND LD.Chainage>=MPR.StartChainage And LD.Chainage<=MPR.EndChainage --AND CI.EndChainage>=MPR.StartChainage And CI.EndChainage<=MPR.EndChainage INNER JOIN NM.MLAConstituency MPc ON MPc.MLACId = MPr.MLACode WHERE MPC.MLAcId= ISNULL (@Searchval , MPC.MLAcId ) AND B.ProcessedYear= ISNULL(@SurveyYear,B.ProcessedYear) AND B.BridgeCode= ISNULL(@BridgeCode,B.BridgeCode) END END GO ALTER PROCEDURE [BMS].[BridgeInventorySpanwise] -- BMS.BridgeInventorySpanwise 'C', NULL, 'thejaswit', 'Rajkot R&B Circle-2',NULL,NULL,'BR:MDR_PND29_002:0000.525' -- BMS.BridgeInventorySpanwise 'C', NULL, 'satya', NULL,NULL,NULL,NULL --@SurveyYear NVARCHAR(100), @SearchType NVARCHAR(5), --='D' , -- C,D,S,ML, MP @SearchVal NVARCHAR (50) = NULL , @User NVARCHAR(100) = NULL, @CName NVARCHAR(100) = NULL, @DName NVARCHAR(100) = NULL, @SubDivision NVARCHAR(100) = NULL, @BridgeCode NVARCHAR(100) = NULL AS BEGIN IF (UPPER(@BridgeCode)= 'NULL' ) set @BridgeCode=NULL declare @userType varchar(20) select @userType = CASE WHEN areatype = 'H' THEN 'HQ' ELSE areatype END from SSUM.[User] where [UserName] =@user IF (@SearchType = 'C' ) BEGIN IF (@searchVal IS NULL or UPPER(@SearchVal) = 'NULL' ) BEGIN If (@userType = 'HQ' ) begin select 'Circle'as SEL,C.CirclesName AS 'Name',LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY C.CirclesName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,SpanNo end else if (@userType = 'D') begin select 'Circle'as SEL,C.CirclesName AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode INNER JOIN NM.Division D on lm.Division = D.DivisionCode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where D.DivisionCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY C.CirclesName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) end else begin select 'Circle'as SEL,C.CirclesName AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where C.CircleCode in (SELECT areaname FROM SSUM.userareas WHERE username =@user) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY C.CirclesName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) end end else if (@userType = 'D') begin select 'Circle'as SEL,C.CirclesName AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode INNER JOIN NM.Division D on lm.Division = D.DivisionCode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where C.CircleCode = @SearchVal AND D.DivisionCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY C.CirclesName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) end ELSE BEGIN select 'Circle'as SEL,C.CirclesName AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where C.CircleCode = @SearchVal and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY C.CirclesName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) End End else if (@SearchType = 'D' ) BEGIN IF (@searchVal IS NULL or UPPER(@SearchVal) = 'NULL' ) BEGIN If (@userType = 'HQ' ) begin select 'Division'AS SEL,D.DivisionName AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode INNER JOIN NM.Division D on lm.Division = D.DivisionCode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionName = ISNULL(@DName, D.DivisionName) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY D.DivisionName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) end else if (@userType in ('C','W')) begin select 'Division'AS SEL,D.DivisionName AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode INNER JOIN NM.Division D on lm.Division = D.DivisionCode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where C.CirclesName = IsNULL(@CName,C.CirclesName) and C.CircleCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY D.DivisionName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) end else --if (@userType = 'D') begin select 'Division'AS SEL,D.DivisionName AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode INNER JOIN NM.Division D on lm.Division = D.DivisionCode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY D.DivisionName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) end End else begin select 'Division'AS SEL,D.DivisionName AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode INNER JOIN NM.Division D on lm.Division = D.DivisionCode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionCode = @SearchVal and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY D.DivisionName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) end end else IF (@SearchType = 'S' ) BEGIN IF (@searchVal IS NULL or UPPER(@SearchVal) = 'NULL' ) BEGIN If (@userType = 'HQ' ) begin select 'Sub Division'AS SEL,SDV.SubDivisionName AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode LEFT JOIN NM.SubDivision SDV on lm.SubDivision = SDV.SubDivisionCode INNER JOIN NM.Division D on lm.Division = D.DivisionCode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionName = ISNULL(@DName, D.DivisionName) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY SDV.SubDivisionName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) End else if(@userType in ('C','W')) begin select 'Sub Division'AS SEL,SDV.SubDivisionName AS 'Name',rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode LEFT JOIN NM.SubDivision SDV on lm.SubDivision = SDV.SubDivisionCode INNER JOIN NM.Division D on lm.Division = D.DivisionCode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where C.CircleCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) and C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionName = ISNULL(@DName, D.DivisionName) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY SDV.SubDivisionName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) end else if(@userType = 'D') begin select 'Sub Division'AS SEL,SDV.SubDivisionName AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode LEFT JOIN NM.SubDivision SDV on lm.SubDivision = SDV.SubDivisionCode INNER JOIN NM.Division D on lm.Division = D.DivisionCode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where D.DivisionCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) and C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionName = ISNULL(@DName, D.DivisionName) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY SDV.SubDivisionName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) end else begin select 'Sub Division'AS SEL,SDV.SubDivisionName AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode LEFT JOIN NM.SubDivision SDV on lm.SubDivision = SDV.SubDivisionCode INNER JOIN NM.Division D on lm.Division = D.DivisionCode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where SDV.SubDivisionCode in ( SELECT areaname FROM SSUM.userareas WHERE username =@user ) and C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionName = ISNULL(@DName, D.DivisionName) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY SDV.SubDivisionName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) end END else begin select 'Sub Division'AS SEL,SDV.SubDivisionName AS 'Name',rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode LEFT JOIN NM.SubDivision SDV on lm.SubDivision = SDV.SubDivisionCode INNER JOIN NM.Division D on lm.Division = D.DivisionCode INNER JOIN NM.Circle C ON lm.circle=C.CircleCode where SDV.SubDivisionCode = @SearchVal and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) --and C.CirclesName = IsNULL(@CName,C.CirclesName) and D.DivisionName = ISNULL(@DName, D.DivisionName) ORDER BY SDV.SubDivisionName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) End End ELSE IF (@SearchType = 'MP' ) BEGIN select 'MP Constituency'AS SEL, MPC.[Name] AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode INNER JOIN NM.MPConstituencyRoad MPr ON MPr.RoadCode = rm.RoadCode AND LD.Chainage>=MPR.StartChainage And LD.Chainage<=MPR.EndChainage INNER JOIN NM.MPConstituency MPc ON MPc.MpcId = MPr.MPCode where MPC.MpcId= ISNULL ( @searchval , MPC.MpcId ) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY MPC.[Name],rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) End else if (@SearchType = 'ML') begin select 'MLA Constituency'AS SEL, MPC.[Name] AS 'Name', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName' ,LD.LinkCode,LD.Chainage,LD.BridgeID,LD.Direction,LD.YearofConstruction,LD.DateofInspection, SD.SpanNo ,LAT.[Description] as 'AbutmentType',AM.[Description] as 'AbutmentMaterial' ,WCT.[Description] as 'WearingCoatType' ,BD.NoofSpoutsPerSpan ,AB.[AbutBearType] as 'AbutmentBearingType' ,AD.ClmnsThcktop,AD.ClmnsThckbttm ,ET.[Description] as 'ExpansionJointsType' ,SD.LongGirderDepth ,FT.[Description] as 'AbutFoundationType',FL.[Description] as 'PierFoundationType' ,PT.[Description] as 'PierType',ARM.[Description] as 'PierMaterial',PD.ClmnsThcktop,PD.ClmnsThckbttm ,PD.PierTopLen, PD.PierBttmLen,PD.PierHeight ,APT.[Description] as 'BearingPier' --,ST.[Description] as 'SuperStructureType', --LST.[Description] 'DeckSlab' ,SD.LongGirderWidth from bms.LocationDetails LD inner join bms.BridgeDetails BD on LD.BridgeID=BD.BridgeCode and LD.SurveyYear=BD.SurveyYear LEFT JOIN bms.LKPTExpjtType ET on BD.ExpnJointType=ET.ExpjtType LEFT JOIN BMS.LKPTWearCoatType WCT on BD.WearingCoatType=WCT.WearCoatType inner JOIN bms.SuperStructureDetails SD on LD.BridgeID=SD.BridgeCode --and LD.SurveyYear=SD.SurveyYear --LEFT JOIN bms.LKPTSupStructType ST on SD.Typeofsuperstructure=ST.SupStructType --LEFT JOIN BMS.LKPTSlabType LST on SD.DeckSlab = LST.SlabType left JOIN bms.AbutmentDetails AD on LD.BridgeID=AD.BridgeCode --And SD.SpanNo=AD.SpanNo and LD.SurveyYear=AD.SurveyYear LEFT JOIN bms.LKPTAbutType LAT on AD.AbtmntType=LAT.AbutType LEFT JOIN bms.LKPTAbutMaterial AM on AD.AbtmntMtrl=AM.AbutMaterialType LEFT JOIN bms.LKPTAbutBearType AB on AD.AbtmntBearingsType=AB.AbutBearType left JOIN bms.FoundationAbutmentInventory FA on LD.BridgeID=FA.BridgeCode and AD.AbtmntNo=FA.AbutmentNo and LD.SurveyYear=FA.SurveyYear LEFT JOIN bms.LKPTFoundType FT on FA.FoundationType=FT.FoundType left JOIN bms.PierDetails PD on LD.BridgeID=PD.BridgeCode --And SD.SpanNo=PD.SpanNo and LD.SurveyYear=PD.SurveyYear LEFT JOIN bms.LKPTPierType PT on PD.PierType=PT.LKPTPierType LEFT JOIN bms.LKPTAbutWallRailMaterType ARM on PD.PierMaterial=ARM.AbutWallRailMaterType LEFT JOIN bms.LKPTAbutBeartype APT on PD.PierBearingsType =APT.AbutBearType left JOIN bms.FoundationPierInventory FI on LD.BridgeID=FI.BridgeCode And SD.SpanNo=FI.SpanNo and PD.PierNo=FI.PierNo and LD.SurveyYear=FI.SurveyYear LEFT JOIN bms.LKPTFoundType FL on FI.FoundationType=FL.FoundType INNER JOIN NM.linkmaster lm ON LD.LinkCode = lm.LinkCode INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode INNER JOIN NM.MLAConstituencyRoad MPr ON MPr.RoadCode = rm.RoadCode AND LD.Chainage>=MPR.StartChainage And LD.Chainage<=MPR.EndChainage INNER JOIN NM.MLAConstituency MPc ON MPc.MLACId = MPr.MLACode where MPC.MLACId= ISNULL ( @searchval , MPC.MLACId ) and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID) --and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear) ORDER BY MPC.[Name],rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,convert(int,SD.SpanNo) End END GO ALTER PROCEDURE [dbo].[GetAbutmentInventoryGridByFilter] --exec [dbo].[GetAbutmentInventoryGridByFilter] 'SHD',NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL --exec [dbo].[GetAbutmentInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'pranusha', 'W',NULL,NULL --exec [dbo].[GetAbutmentInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL --exec [dbo].[GetAbutmentInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF (@userType = 'H' and @hType is NULL) BEGIN SELECT [BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)', ld.[Direction], --convert(varchar, hyd.DateofInventory, 11) as 'Date of Inventory', ld.[SurveyYear] as 'Survey Year', Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'Abutment No', lkptAT.[Description] as 'Abutment Type', lkptABT.[Description] as 'Bearing Type',lkptF.[Description] as 'Abutment Foundation Type' ,hd.DateofInspection ,lkptF.Description as FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=hd.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=hd.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=hd.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=hd.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=hd.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType LEFT OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode --LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage END else IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL) BEGIN SELECT [BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)', ld.[Direction], --convert(varchar, hyd.DateofInventory, 11) as 'Date of Inventory', ld.[SurveyYear] as 'Survey Year', Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'Abutment No', lkptAT.[Description] as 'Abutment Type', lkptABT.[Description] as 'Bearing Type',lkptF.[Description] as 'Abutment Foundation Type' ,hd.DateofInspection ,lkptF.Description as FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=hd.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=hd.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=hd.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=hd.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=hd.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType LEFT OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode --LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage END else IF (@userType = 'D' and @hType is NULL) BEGIN SELECT [BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)', ld.[Direction], --convert(varchar, hyd.DateofInventory, 11) as 'Date of Inventory', ld.[SurveyYear] as 'Survey Year', Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'Abutment No', lkptAT.[Description] as 'Abutment Type', lkptABT.[Description] as 'Bearing Type',lkptF.[Description] as 'Abutment Foundation Type' ,hd.DateofInspection ,lkptF.Description as FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=hd.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=hd.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=hd.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=hd.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=hd.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType LEFT OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode --LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage END ELSE BEGIN IF @hType = 'C' BEGIN SELECT [BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)', ld.[Direction], --convert(varchar, hyd.DateofInventory, 11) as 'Date of Inventory', ld.[SurveyYear] as 'Survey Year', Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'Abutment No', lkptAT.[Description] as 'Abutment Type', lkptABT.[Description] as 'Bearing Type',lkptF.[Description] as 'Abutment Foundation Type' ,hd.DateofInspection ,lkptF.Description as FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=hd.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=hd.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=hd.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=hd.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=hd.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType LEFT OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode --LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle = @hTypeVal AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage END else IF @hType = 'D' BEGIN SELECT [BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)', ld.[Direction], --convert(varchar, hyd.DateofInventory, 11) as 'Date of Inventory', ld.[SurveyYear] as 'Survey Year', Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'Abutment No', lkptAT.[Description] as 'Abutment Type', lkptABT.[Description] as 'Bearing Type',lkptF.[Description] as 'Abutment Foundation Type' ,hd.DateofInspection ,lkptF.Description as FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=hd.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=hd.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=hd.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=hd.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=hd.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType LEFT OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode --LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division = @hTypeVal AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage END else IF @hType = 'W' BEGIN SELECT [BridgeID] as 'Bridge Code',CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)', ld.[Direction], --convert(varchar, hyd.DateofInventory, 11) as 'Date of Inventory', ld.[SurveyYear] as 'Survey Year', Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'Abutment No', lkptAT.[Description] as 'Abutment Type', lkptABT.[Description] as 'Bearing Type',lkptF.[Description] as 'Abutment Foundation Type' ,hd.DateofInspection ,lkptF.Description as FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=hd.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=hd.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=hd.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=hd.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=hd.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType LEFT OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode --LEFT OUTER JOIN BMS.HydraulicDetails HyD ON ld.BridgeID=hyd.BridgeCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage END END end GO ALTER PROCEDURE [dbo].[GetAbutmentInventoryByFilter] --exec [dbo].[GetAbutmentInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL --exec [dbo].[GetAbutmentInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL --exec [dbo].[GetAbutmentInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL --exec [dbo].[GetAbutmentInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'pranusha', 'W',NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF(@userType = 'H' and @hType is NULL) Begin select BridgeCode as 'Bridge Code' ,AbtmntNo ,lkptAT.[Description] as 'Abutment Type' ,am.[Description] as 'Abutment Cap Material' ,ClmnsCount as 'Number of Columns' ,ClmnsThcktop as 'Thickness Top' ,ClmnsThckbttm as 'Thickness Bottom' ,ClmnsHeight ,CapLength as 'Length of Cap' ,CapWidth as 'Width of Cap' --,dt.[Description] as 'Dirt Wall Material Type' ,DrtWallThck as 'Dirt wall Thickness' ,DrtWallHeight as 'Dirt Wall Height' --,awt.[Description] as 'Abutment Wall Type' --,awt1.[Description] as 'Abutment Wall Material Type' --,wt.[Description] as 'Abutment wall Railing type' --,rt.[Description] as 'Abutment wall Railing Material type' ,abt.[Description] as 'Bearing Abutment Type' ,BearingsCount as 'No of Bearings' ,A.Remarks AbtmntBearingsType ,BearingsCount ,a.DateofInspection ,lkptF.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType,BearingsPrvd from BMS.AbutmentDetails A inner join BMS.LocationDetails ld on A.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=A.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType lkptAT ON lkptAT.AbutType=A.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=A.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=a.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=a.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=a.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=a.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=a.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=A.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=A.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=A.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=A.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=A.AbutmentwallRailingMaterialtype WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' -- ,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' -- ,Raftlength as 'Length of Raft' -- ,NoofWells as 'No of Wells' -- ,DiaofWell as 'Dia of Well' -- ,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=F.FoundationType WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge Code' ,Ap.SurveyYear as 'Survey Year' ,SpanNo ,AbutmentNumber ,ps.Side ,WallType as 'Wall Type' ,MaterialType as 'Material Type' ,ApproachProtectionWallType as 'Wall Type' --,WallLngth as 'Wall Length' --,WallHght as 'Wall Height' ,[location] as 'Location' ,Ap.Remarks from BMS.ApproachProtectionInventory Ap inner join BMS.LocationDetails ld on Ap.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT JOIN BMS.LKPTAppWallType BT ON AP.WallType = BT.AppWallType LEFT JOIN BMS.LKPTAbutMaterial BG ON AP.MaterialType = BG.AbutMaterialType LEFT JOIN BMS.LKPTProtectionSide ps ON ps.Side=AP.Side WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage End IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL) BEGIN select BridgeCode as 'Bridge Code' ,AbtmntNo ,lkptAT.[Description] as 'Abutment Type' ,am.[Description] as 'Abutment Cap Material' ,ClmnsCount as 'Number of Columns' ,ClmnsThcktop as 'Thickness Top' ,ClmnsThckbttm as 'Thickness Bottom' ,ClmnsHeight ,CapLength as 'Length of Cap' ,CapWidth as 'Width of Cap' --,dt.[Description] as 'Dirt Wall Material Type' ,DrtWallThck as 'Dirt wall Thickness' ,DrtWallHeight as 'Dirt Wall Height' --,awt.[Description] as 'Abutment Wall Type' --,awt1.[Description] as 'Abutment Wall Material Type' --,wt.[Description] as 'Abutment wall Railing type' --,rt.[Description] as 'Abutment wall Railing Material type' ,abt.[Description] as 'Bearing Abutment Type' ,BearingsCount as 'No of Bearings' ,A.Remarks AbtmntBearingsType ,BearingsCount ,a.DateofInspection ,lkptF.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType,BearingsPrvd from BMS.AbutmentDetails A inner join BMS.LocationDetails ld on A.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=A.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType lkptAT ON lkptAT.AbutType=A.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=A.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=a.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=a.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=a.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=a.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=a.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=A.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=A.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=A.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=A.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=A.AbutmentwallRailingMaterialtype WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' --,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' --,Raftlength as 'Length of Raft' --,NoofWells as 'No of Wells' --,DiaofWell as 'Dia of Well' --,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=F.FoundationType WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage End ELSE IF (@userType = 'D' and @hType is NULL) BEGIN select BridgeCode as 'Bridge Code' ,AbtmntNo ,lkptAT.[Description] as 'Abutment Type' ,am.[Description] as 'Abutment Cap Material' ,ClmnsCount as 'Number of Columns' ,ClmnsThcktop as 'Thickness Top' ,ClmnsThckbttm as 'Thickness Bottom' ,ClmnsHeight ,CapLength as 'Length of Cap' ,CapWidth as 'Width of Cap' --,dt.[Description] as 'Dirt Wall Material Type' ,DrtWallThck as 'Dirt wall Thickness' ,DrtWallHeight as 'Dirt Wall Height' --,awt.[Description] as 'Abutment Wall Type' --,awt1.[Description] as 'Abutment Wall Material Type' --,wt.[Description] as 'Abutment wall Railing type' --,rt.[Description] as 'Abutment wall Railing Material type' ,abt.[Description] as 'Bearing Abutment Type' ,BearingsCount as 'No of Bearings' ,A.Remarks AbtmntBearingsType ,BearingsCount ,a.DateofInspection ,lkptF.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType,BearingsPrvd from BMS.AbutmentDetails A inner join BMS.LocationDetails ld on A.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=A.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType lkptAT ON lkptAT.AbutType=A.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=A.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=a.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=a.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=a.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=a.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=a.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=A.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=A.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=A.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=A.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=A.AbutmentwallRailingMaterialtype WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' --,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' --,Raftlength as 'Length of Raft' --,NoofWells as 'No of Wells' --,DiaofWell as 'Dia of Well' --,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=F.FoundationType WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' --,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' --,Raftlength as 'Length of Raft' --,NoofWells as 'No of Wells' --,DiaofWell as 'Dia of Well' --,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=F.FoundationType WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage End ELSE IF (@hType = 'C' OR @hType = 'W') BEGIN select BridgeCode as 'Bridge Code' ,AbtmntNo ,lkptAT.[Description] as 'Abutment Type' ,am.[Description] as 'Abutment Cap Material' ,ClmnsCount as 'Number of Columns' ,ClmnsThcktop as 'Thickness Top' ,ClmnsThckbttm as 'Thickness Bottom' ,ClmnsHeight ,CapLength as 'Length of Cap' ,CapWidth as 'Width of Cap' --,dt.[Description] as 'Dirt Wall Material Type' ,DrtWallThck as 'Dirt wall Thickness' ,DrtWallHeight as 'Dirt Wall Height' --,awt.[Description] as 'Abutment Wall Type' --,awt1.[Description] as 'Abutment Wall Material Type' --,wt.[Description] as 'Abutment wall Railing type' --,rt.[Description] as 'Abutment wall Railing Material type' ,abt.[Description] as 'Bearing Abutment Type' ,BearingsCount as 'No of Bearings' ,A.Remarks AbtmntBearingsType ,BearingsCount ,a.DateofInspection ,lkptF.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType,BearingsPrvd from BMS.AbutmentDetails A inner join BMS.LocationDetails ld on A.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=A.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType lkptAT ON lkptAT.AbutType=A.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=A.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=a.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=a.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=a.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=a.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=a.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=A.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=A.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=A.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=A.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=A.AbutmentwallRailingMaterialtype WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle = @hTypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' --,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' --,Raftlength as 'Length of Raft' --,NoofWells as 'No of Wells' --,DiaofWell as 'Dia of Well' --,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=F.FoundationType WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle = @hTypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' --,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' --,Raftlength as 'Length of Raft' --,NoofWells as 'No of Wells' --,DiaofWell as 'Dia of Well' --,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=F.FoundationType WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle = @hTypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage End ELSE IF @hType = 'D' BEGIN select BridgeCode as 'Bridge Code' ,AbtmntNo ,lkptAT.[Description] as 'Abutment Type' ,am.[Description] as 'Abutment Cap Material' ,ClmnsCount as 'Number of Columns' ,ClmnsThcktop as 'Thickness Top' ,ClmnsThckbttm as 'Thickness Bottom' ,ClmnsHeight ,CapLength as 'Length of Cap' ,CapWidth as 'Width of Cap' --,dt.[Description] as 'Dirt Wall Material Type' ,DrtWallThck as 'Dirt wall Thickness' ,DrtWallHeight as 'Dirt Wall Height' --,awt.[Description] as 'Abutment Wall Type' --,awt1.[Description] as 'Abutment Wall Material Type' --,wt.[Description] as 'Abutment wall Railing type' --,rt.[Description] as 'Abutment wall Railing Material type' ,abt.[Description] as 'Bearing Abutment Type' ,BearingsCount as 'No of Bearings' ,A.Remarks AbtmntBearingsType ,BearingsCount ,a.DateofInspection ,lkptF.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType,BearingsPrvd from BMS.AbutmentDetails A inner join BMS.LocationDetails ld on A.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=A.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType lkptAT ON lkptAT.AbutType=A.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=A.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=a.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=a.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=a.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=a.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=a.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=A.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=A.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=A.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=A.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=A.AbutmentwallRailingMaterialtype WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division = @hTypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' --,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' --,Raftlength as 'Length of Raft' --,NoofWells as 'No of Wells' --,DiaofWell as 'Dia of Well' --,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=F.FoundationType WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division = @hTypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' --,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' --,Raftlength as 'Length of Raft' --,NoofWells as 'No of Wells' --,DiaofWell as 'Dia of Well' --,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=F.FoundationType WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division = @hTypeVal AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage End ELSE IF @hType = 'MLA' BEGIN select BridgeCode as 'Bridge Code' ,AbtmntNo ,lkptAT.[Description] as 'Abutment Type' ,am.[Description] as 'Abutment Cap Material' ,ClmnsCount as 'Number of Columns' ,ClmnsThcktop as 'Thickness Top' ,ClmnsThckbttm as 'Thickness Bottom' ,ClmnsHeight ,CapLength as 'Length of Cap' ,CapWidth as 'Width of Cap' --,dt.[Description] as 'Dirt Wall Material Type' ,DrtWallThck as 'Dirt wall Thickness' ,DrtWallHeight as 'Dirt Wall Height' --,awt.[Description] as 'Abutment Wall Type' --,awt1.[Description] as 'Abutment Wall Material Type' --,wt.[Description] as 'Abutment wall Railing type' --,rt.[Description] as 'Abutment wall Railing Material type' ,abt.[Description] as 'Bearing Abutment Type' ,BearingsCount as 'No of Bearings' ,A.Remarks AbtmntBearingsType ,BearingsCount ,a.DateofInspection ,lkptF.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType,BearingsPrvd from BMS.AbutmentDetails A inner join BMS.LocationDetails ld on A.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=A.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType lkptAT ON lkptAT.AbutType=A.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=A.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=a.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=a.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=a.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=a.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=a.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=A.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=A.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=A.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=A.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=A.AbutmentwallRailingMaterialtype inner join NM.MLAConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MLACode = ISNULL(@hTypeVal,mcr.MLACode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' --,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' --,Raftlength as 'Length of Raft' --,NoofWells as 'No of Wells' --,DiaofWell as 'Dia of Well' --,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=F.FoundationType inner join NM.MLAConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MLACode = ISNULL(@hTypeVal,mcr.MLACode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' --,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' --,Raftlength as 'Length of Raft' --,NoofWells as 'No of Wells' --,DiaofWell as 'Dia of Well' --,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=f.AbutmentNo inner join NM.MLAConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MLACode = ISNULL(@hTypeVal,mcr.MLACode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage End ELSE IF @hType = 'MP' BEGIN select BridgeCode as 'Bridge Code' ,AbtmntNo ,lkptAT.[Description] as 'Abutment Type' ,am.[Description] as 'Abutment Cap Material' ,ClmnsCount as 'Number of Columns' ,ClmnsThcktop as 'Thickness Top' ,ClmnsThckbttm as 'Thickness Bottom' ,ClmnsHeight ,CapLength as 'Length of Cap' ,CapWidth as 'Width of Cap' --,dt.[Description] as 'Dirt Wall Material Type' ,DrtWallThck as 'Dirt wall Thickness' ,DrtWallHeight as 'Dirt Wall Height' --,awt.[Description] as 'Abutment Wall Type' --,awt1.[Description] as 'Abutment Wall Material Type' --,wt.[Description] as 'Abutment wall Railing type' --,rt.[Description] as 'Abutment wall Railing Material type' ,abt.[Description] as 'Bearing Abutment Type' ,BearingsCount as 'No of Bearings' ,A.Remarks AbtmntBearingsType ,BearingsCount ,a.DateofInspection ,lkptF.Description as FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,am.Description as FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,lkptrt.Description as RetningWallType ,lkptrm.Description as RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,lkptsm.Description as SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,lkptwt.Description as WellType,BearingsPrvd from BMS.AbutmentDetails A inner join BMS.LocationDetails ld on A.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=A.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType lkptAT ON lkptAT.AbutType=A.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=A.AbtmntBearingsType LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=a.FndtionType left outer join [BMS].[LKPTRetningType] lkptrt on lkptrt.RetningType=a.RetningWallType left outer join [BMS].[LKPTRetningMtrl] lkptrm on lkptrm.RetningMtrlType=a.RetningWallMtrl left outer join [BMS].[LKPTSmcMtrl] lkptsm on lkptsm.SmcMtrlType=a.SmcRstnrMtrl left outer join [BMS].[LKPTWellType] lkptwt on lkptwt.WellType=a.WellType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=A.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=A.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=A.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=A.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=A.AbutmentwallRailingMaterialtype inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' --,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' --,Raftlength as 'Length of Raft' --,NoofWells as 'No of Wells' --,DiaofWell as 'Dia of Well' --,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=F.FoundationType inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage select BridgeCode as 'Bridge code' ,F.SurveyYear as 'Survey Year' ,SpanNo ,f.AbutmentNo ,lkptF.[Description] as 'Foundation Type' --,RaftWidth as 'Width of Raft' --,RaftThick as 'Thickness of Raft' --,Raftlength as 'Length of Raft' --,NoofWells as 'No of Wells' --,DiaofWell as 'Dia of Well' --,WellDepth as 'Length of Depth of Well' ,F.Remarks from BMS.FoundationAbutmentInventory F inner join BMS.LocationDetails ld on F.BridgeCode = ld.BridgeID inner join NM.LinkMaster lm on ld.LinkCode = lm.LinkCode LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=F.FoundationType inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND ld.TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc, ld.RoadCode, ld.Chainage End END GO ALTER PROCEDURE [dbo].[GetAbutmentDetailsByFilter] -- exec [dbo].[GetAbutmentDetailsByFilter] NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL -- exec [dbo].[GetAbutmentDetailsByFilter] NULL,NULL,NULL,NULL,NULL,'pranusha', 'W',NULL,NULL -- exec [dbo].[GetAbutmentDetailsByFilter] NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL -- exec [dbo].[GetAbutmentDetailsByFilter] NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF(@userType = 'H' and @hType is NULL) Begin SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',Chainage,ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrAbutDetID], hd.[BridgeCode],ld.[SurveyYear]--, Case When hd.[SpanNo] IS NOT NULL THEN hd.[SpanNo] ELSE FAI.[SpanNo] END 'SpanNo' , Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'AbtmntNo' , lkptAT.Description as AbutmentType, [AbtmntMtrl], [ClmnsCount], [ClmnsThcktop], [ClmnsThckbttm], [ClmnsHeight], [CapLength], [CapWidth], --[CapHeight], [DrtWallThck], [DrtWallHeight], [AbtmntBearingsType], [BearingsCount], HD.[Remarks],am.Description AbutmentMaterialDescription,at.Description AbutmentTypeDescription,abt.Description BearingAbutmentTypeDescription,--awt.Description AbutmentWallTypeDescription, --awt1.Description AbutmentWallMaterialTypeDescription, dt.Description DirtWallMaterialTypeDescription,wt.Description AbutmentwallRailingtypeDescription,rt.Description AbutmentwallRailingMaterialtypeDescription CASE WHEN (hd.[BridgeCode] IS NOT NULL OR FAI.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END ApprovalStatus ,lkptABT.Description as BearingType,lkptF.Description as AbutmentFoundationType ,ld.DateOfInspection as 'DateofInventory', hd.DateofInspection ,FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,RetningWallType ,RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,WellType ,BearingsPrvd FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType FULL OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=FAI.FoundationType --LEFT OUTER JOIN BMS.HydraulicDetails Hyd ON ld.BridgeID=hyd.BridgeCode INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,AbtmntNo END IF (@userType = 'C' and @hType is NULL) BEGIN SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',Chainage,ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrAbutDetID], hd.[BridgeCode],ld.[SurveyYear]--, Case When hd.[SpanNo] IS NOT NULL THEN hd.[SpanNo] ELSE FAI.[SpanNo] END 'SpanNo' , Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'AbtmntNo' , lkptAT.Description as AbutmentType, [AbtmntMtrl], [ClmnsCount], [ClmnsThcktop], [ClmnsThckbttm], [ClmnsHeight], [CapLength], [CapWidth], --[CapHeight], [DrtWallThck], [DrtWallHeight], [AbtmntBearingsType], [BearingsCount], HD.[Remarks],am.Description AbutmentMaterialDescription,at.Description AbutmentTypeDescription,abt.Description BearingAbutmentTypeDescription,--awt.Description AbutmentWallTypeDescription, --awt1.Description AbutmentWallMaterialTypeDescription, dt.Description DirtWallMaterialTypeDescription,wt.Description AbutmentwallRailingtypeDescription,rt.Description AbutmentwallRailingMaterialtypeDescription CASE WHEN (hd.[BridgeCode] IS NOT NULL OR FAI.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END ApprovalStatus ,lkptABT.Description as BearingType,lkptF.Description as AbutmentFoundationType ,ld.DateOfInspection as 'DateofInventory', hd.DateofInspection ,FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,RetningWallType ,RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,WellType ,BearingsPrvd FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType FULL OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=FAI.FoundationType --LEFT OUTER JOIN BMS.HydraulicDetails Hyd ON ld.BridgeID=hyd.BridgeCode INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode --LEFT OUTER JOIN BMS.HydraulicDetails Hyd ON ld.BridgeID=hyd.BridgeCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,AbtmntNo END ELSE IF (@userType = 'D' and @hType is NULL) BEGIN SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',Chainage,ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrAbutDetID], hd.[BridgeCode],ld.[SurveyYear]--, Case When hd.[SpanNo] IS NOT NULL THEN hd.[SpanNo] ELSE FAI.[SpanNo] END 'SpanNo' , Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'AbtmntNo' , lkptAT.Description as AbutmentType, [AbtmntMtrl], [ClmnsCount], [ClmnsThcktop], [ClmnsThckbttm], [ClmnsHeight], [CapLength], [CapWidth], --[CapHeight], [DrtWallThck], [DrtWallHeight], [AbtmntBearingsType], [BearingsCount], HD.[Remarks],am.Description AbutmentMaterialDescription,at.Description AbutmentTypeDescription,abt.Description BearingAbutmentTypeDescription,--awt.Description AbutmentWallTypeDescription, --awt1.Description AbutmentWallMaterialTypeDescription, dt.Description DirtWallMaterialTypeDescription,wt.Description AbutmentwallRailingtypeDescription,rt.Description AbutmentwallRailingMaterialtypeDescription CASE WHEN (hd.[BridgeCode] IS NOT NULL OR FAI.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END ApprovalStatus ,lkptABT.Description as BearingType,lkptF.Description as AbutmentFoundationType ,ld.DateOfInspection as 'DateofInventory', hd.DateofInspection ,FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,RetningWallType ,RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,WellType ,BearingsPrvd FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType FULL OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=FAI.FoundationType --LEFT OUTER JOIN BMS.HydraulicDetails Hyd ON ld.BridgeID=hyd.BridgeCode INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,AbtmntNo END ELSE IF (@userType = 'W' and @hType is NULL) BEGIN SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',Chainage,ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrAbutDetID], hd.[BridgeCode],ld.[SurveyYear]--, Case When hd.[SpanNo] IS NOT NULL THEN hd.[SpanNo] ELSE FAI.[SpanNo] END 'SpanNo' , Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'AbtmntNo' , lkptAT.Description as AbutmentType, [AbtmntMtrl], [ClmnsCount], [ClmnsThcktop], [ClmnsThckbttm], [ClmnsHeight], [CapLength], [CapWidth], --[CapHeight], [DrtWallThck], [DrtWallHeight], [AbtmntBearingsType], [BearingsCount], HD.[Remarks],am.Description AbutmentMaterialDescription,at.Description AbutmentTypeDescription,abt.Description BearingAbutmentTypeDescription,--awt.Description AbutmentWallTypeDescription, --awt1.Description AbutmentWallMaterialTypeDescription, dt.Description DirtWallMaterialTypeDescription,wt.Description AbutmentwallRailingtypeDescription,rt.Description AbutmentwallRailingMaterialtypeDescription CASE WHEN (hd.[BridgeCode] IS NOT NULL OR FAI.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END ApprovalStatus ,lkptABT.Description as BearingType,lkptF.Description as AbutmentFoundationType ,ld.DateOfInspection as 'DateofInventory', hd.DateofInspection ,FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,RetningWallType ,RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,WellType ,BearingsPrvd FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType FULL OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=FAI.FoundationType --LEFT OUTER JOIN BMS.HydraulicDetails Hyd ON ld.BridgeID=hyd.BridgeCode INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,AbtmntNo END ELSE BEGIN IF @hType = 'C' BEGIN SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',Chainage,ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrAbutDetID], hd.[BridgeCode],ld.[SurveyYear]--, Case When hd.[SpanNo] IS NOT NULL THEN hd.[SpanNo] ELSE FAI.[SpanNo] END 'SpanNo' , Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'AbtmntNo' , lkptAT.Description as AbutmentType, [AbtmntMtrl], [ClmnsCount], [ClmnsThcktop], [ClmnsThckbttm], [ClmnsHeight], [CapLength], [CapWidth], --[CapHeight], [DrtWallThck], [DrtWallHeight], [AbtmntBearingsType], [BearingsCount], HD.[Remarks],am.Description AbutmentMaterialDescription,at.Description AbutmentTypeDescription,abt.Description BearingAbutmentTypeDescription,--awt.Description AbutmentWallTypeDescription, --awt1.Description AbutmentWallMaterialTypeDescription, dt.Description DirtWallMaterialTypeDescription,wt.Description AbutmentwallRailingtypeDescription,rt.Description AbutmentwallRailingMaterialtypeDescription CASE WHEN (hd.[BridgeCode] IS NOT NULL OR FAI.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END ApprovalStatus ,lkptABT.Description as BearingType,lkptF.Description as AbutmentFoundationType ,ld.DateOfInspection as 'DateofInventory', hd.DateofInspection ,FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,RetningWallType ,RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,WellType ,BearingsPrvd FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType FULL OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=FAI.FoundationType --LEFT OUTER JOIN BMS.HydraulicDetails Hyd ON ld.BridgeID=hyd.BridgeCode INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Circle = @hTypeVal AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,AbtmntNo END ELSE IF @hType = 'D' BEGIN SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',Chainage,ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrAbutDetID], hd.[BridgeCode],ld.[SurveyYear]--, Case When hd.[SpanNo] IS NOT NULL THEN hd.[SpanNo] ELSE FAI.[SpanNo] END 'SpanNo' , Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'AbtmntNo' , lkptAT.Description as AbutmentType, [AbtmntMtrl], [ClmnsCount], [ClmnsThcktop], [ClmnsThckbttm], [ClmnsHeight], [CapLength], [CapWidth], --[CapHeight], [DrtWallThck], [DrtWallHeight], [AbtmntBearingsType], [BearingsCount], HD.[Remarks],am.Description AbutmentMaterialDescription,at.Description AbutmentTypeDescription,abt.Description BearingAbutmentTypeDescription,--awt.Description AbutmentWallTypeDescription, --awt1.Description AbutmentWallMaterialTypeDescription, dt.Description DirtWallMaterialTypeDescription,wt.Description AbutmentwallRailingtypeDescription,rt.Description AbutmentwallRailingMaterialtypeDescription CASE WHEN (hd.[BridgeCode] IS NOT NULL OR FAI.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END ApprovalStatus ,lkptABT.Description as BearingType,lkptF.Description as AbutmentFoundationType ,ld.DateOfInspection as 'DateofInventory', hd.DateofInspection ,FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,RetningWallType ,RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,WellType ,BearingsPrvd FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType FULL OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=FAI.FoundationType --LEFT OUTER JOIN BMS.HydraulicDetails Hyd ON ld.BridgeID=hyd.BridgeCode INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND lm.Division = @hTypeVal AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,AbtmntNo END ELSE IF @hType = 'W' BEGIN SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',Chainage,ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrAbutDetID], hd.[BridgeCode],ld.[SurveyYear]--, Case When hd.[SpanNo] IS NOT NULL THEN hd.[SpanNo] ELSE FAI.[SpanNo] END 'SpanNo' , Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'AbtmntNo' , lkptAT.Description as AbutmentType, [AbtmntMtrl], [ClmnsCount], [ClmnsThcktop], [ClmnsThckbttm], [ClmnsHeight], [CapLength], [CapWidth], --[CapHeight], [DrtWallThck], [DrtWallHeight], [AbtmntBearingsType], [BearingsCount], HD.[Remarks],am.Description AbutmentMaterialDescription,at.Description AbutmentTypeDescription,abt.Description BearingAbutmentTypeDescription,--awt.Description AbutmentWallTypeDescription, --awt1.Description AbutmentWallMaterialTypeDescription, dt.Description DirtWallMaterialTypeDescription,wt.Description AbutmentwallRailingtypeDescription,rt.Description AbutmentwallRailingMaterialtypeDescription CASE WHEN (hd.[BridgeCode] IS NOT NULL OR FAI.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END ApprovalStatus ,lkptABT.Description as BearingType,lkptF.Description as AbutmentFoundationType ,ld.DateOfInspection as 'DateofInventory', hd.DateofInspection ,FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,RetningWallType ,RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,WellType ,BearingsPrvd FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType FULL OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=FAI.FoundationType --LEFT OUTER JOIN BMS.HydraulicDetails Hyd ON ld.BridgeID=hyd.BridgeCode INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) /* Commented on 11/27/2020*/ AND lm.Circle IN(SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,AbtmntNo END ELSE IF @hType = 'MLA' BEGIN SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',Chainage,ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrAbutDetID], hd.[BridgeCode],ld.[SurveyYear]--, Case When hd.[SpanNo] IS NOT NULL THEN hd.[SpanNo] ELSE FAI.[SpanNo] END 'SpanNo' , Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'AbtmntNo' , lkptAT.Description as AbutmentType, [AbtmntMtrl], [ClmnsCount], [ClmnsThcktop], [ClmnsThckbttm], [ClmnsHeight], [CapLength], [CapWidth], --[CapHeight], [DrtWallThck], [DrtWallHeight], [AbtmntBearingsType], [BearingsCount], HD.[Remarks],am.Description AbutmentMaterialDescription,at.Description AbutmentTypeDescription,abt.Description BearingAbutmentTypeDescription,--awt.Description AbutmentWallTypeDescription, --awt1.Description AbutmentWallMaterialTypeDescription, dt.Description DirtWallMaterialTypeDescription,wt.Description AbutmentwallRailingtypeDescription,rt.Description AbutmentwallRailingMaterialtypeDescription CASE WHEN (hd.[BridgeCode] IS NOT NULL OR FAI.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END ApprovalStatus ,lkptABT.Description as BearingType,lkptF.Description as AbutmentFoundationType ,ld.DateOfInspection as 'DateofInventory', hd.DateofInspection ,FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,RetningWallType ,RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,WellType ,BearingsPrvd FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType FULL OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=FAI.FoundationType --LEFT OUTER JOIN BMS.HydraulicDetails Hyd ON ld.BridgeID=hyd.BridgeCode INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,AbtmntNo END ELSE IF @hType = 'MP' BEGIN SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',Chainage,ld.[LinkCode], ld.[Direction], [BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],hd.DateofInspection, [BrdgSubStrAbutDetID], hd.[BridgeCode],ld.[SurveyYear]--, Case When hd.[SpanNo] IS NOT NULL THEN hd.[SpanNo] ELSE FAI.[SpanNo] END 'SpanNo' , Case When hd.[AbtmntNo] IS NOT NULL THEN hd.[AbtmntNo] ELSE FAI.AbutmentNo END 'AbtmntNo' , lkptAT.Description as AbutmentType, [AbtmntMtrl], [ClmnsCount], [ClmnsThcktop], [ClmnsThckbttm], [ClmnsHeight], [CapLength], [CapWidth], --[CapHeight], [DrtWallThck], [DrtWallHeight], [AbtmntBearingsType], [BearingsCount], HD.[Remarks],am.Description AbutmentMaterialDescription,at.Description AbutmentTypeDescription,abt.Description BearingAbutmentTypeDescription,--awt.Description AbutmentWallTypeDescription, --awt1.Description AbutmentWallMaterialTypeDescription, dt.Description DirtWallMaterialTypeDescription,wt.Description AbutmentwallRailingtypeDescription,rt.Description AbutmentwallRailingMaterialtypeDescription CASE WHEN (hd.[BridgeCode] IS NOT NULL OR FAI.[BridgeCode] IS NOT NULL) THEN 'Approved' ELSE 'New' END ApprovalStatus ,lkptABT.Description as BearingType,lkptF.Description as AbutmentFoundationType ,ld.DateOfInspection as 'DateofInventory', hd.DateofInspection ,FndtionType ,hd.RaftWidth ,hd.Raftlength ,NoofPiles ,WlPlDiameter ,hd.WellDepth ,FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,RetningWallType ,RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,WellType ,BearingsPrvd FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID --LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN [BMS].LKPTAbutMaterial am ON am.AbutMaterialType=hd.AbtmntMtrl LEFT OUTER JOIN [BMS].LKPTAbutType at ON at.AbutType=hd.AbtmntType LEFT OUTER JOIN [BMS].LKPTAbutBearType abt ON abt.AbutBearType=hd.AbtmntBearingsType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt ON awt.AbutWallType=hd.AbutmentWallType --LEFT OUTER JOIN [BMS].LKPTAbutWallType awt1 ON awt1.AbutWallType=hd.AbutmentWallMaterialType --LEFT OUTER JOIN [BMS].LKPTDWMaterType dt ON dt.DWMaterType=hd.DrtWallMtrlType --LEFT OUTER JOIN [BMS].LKPTAbutWallrailType wt ON wt.AbutWallrailType=hd.AbutmentwallRailingtype --LEFT OUTER JOIN [BMS].LKPTAbutWallRailMaterType rt ON rt.AbutWallRailMaterType=hd.AbutmentwallRailingMaterialtype LEFT OUTER JOIN [BMS].[LKPTAbutType] lkptAT ON lkptAT.AbutType =hd.AbtmntType LEFT OUTER JOIN [BMS].[LKPTAbutBearType] lkptABT ON lkptABT.AbutBearType =hd.AbtmntBearingsType FULL OUTER JOIN BMS.FoundationAbutmentInventory FAI ON ld.BridgeID=FAI.BridgeCode and hd.AbtmntNo = FAI.AbutmentNo LEFT OUTER JOIN BMS.LKPTFoundType lkptF ON lkptF.FoundType=FAI.FoundationType --LEFT OUTER JOIN BMS.HydraulicDetails Hyd ON ld.BridgeID=hyd.BridgeCode INNER JOIN NM.LinkMaster lm on ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.RoadCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) AND ld.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND ld.Chainage <=ISNULL(@EndChainage, ld.Chainage) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID) Order by lm.IsPilot desc,ld.RoadCode,ld.Chainage,AbtmntNo END END END GO ALTER PROCEDURE [dbo].[GetAbutmentDetailsByBridgeCode] --'BR:NH030:0000.500' ( @bridgeCode VARCHAR(100)=NULL, @surveyYear VARCHAR(100)=NULL, @spanNo VARCHAR(10) = NULL, @tableFlag VARCHAR(10)=NULL ) AS BEGIN IF @tableFlag = 'M' BEGIN SELECT BrdgSubStrAbutDetID, BridgeCode, AbtmntNo, AbtmntType, AbtmntMtrl, ClmnsCount, ClmnsThcktop, ClmnsThckbttm, ClmnsHeight, CapLength, CapWidth, DrtWallThck, DrtWallHeight, AbtmntBearingsType, BearingsCount, hd.Remarks, hd.DateofInspection ,FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,RetningWallType ,RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,WellType ,BearingsPrvd FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID WHERE BridgeCode = @bridgeCode --AND hd.SurveyYear = @surveyYear --AND SpanNo=@spanNo END ELSE BEGIN SELECT BrdgSubStrAbutDetID, BridgeCode, AbtmntNo, AbtmntType, AbtmntMtrl, ClmnsCount, ClmnsThcktop, ClmnsThckbttm, ClmnsHeight, CapLength, CapWidth, DrtWallThck, DrtWallHeight, AbtmntBearingsType, BearingsCount, hd.Remarks, hd.DateofInspection ,FndtionType ,RaftWidth ,Raftlength ,NoofPiles ,WlPlDiameter ,WellDepth ,FndtionMtrlType ,ClmnsLenatTop ,ClmnsLenatBttm ,capThick ,DrtWallLength ,WeepHolesPrvd ,WeepHolesCount ,RetningWallType ,RetningWallMtrl ,LengthonEachSide ,BearingsVisible ,SmcRstnrPrvd ,SmcRstnrMtrl ,SmcRstnrLoc ,PileWidth ,WellType ,BearingsPrvd FROM [BMS].[AbutmentDetails] hd LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID WHERE BridgeCode = @bridgeCode --AND hd.SurveyYear = @surveyYear --AND SpanNo=@spanNo END END GO ALTER PROCEDURE [dbo].[GetBridgeInventoryGridByFilter] --exec [dbo].[GetBridgeInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL --exec [dbo].[GetBridgeInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL --exec [dbo].[GetBridgeInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL --exec [dbo].[GetBridgeInventoryGridByFilter] NULL,NULL,NULL,NULL,NULL,'pranusha', 'W',NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF @userType = 'H' BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year', Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END else bd.Remarks END else ld.Remarks END 'Remarks' ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMaterialType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS PipeMaterial FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END ELSE IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL) BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year',Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END 'Remarks' FROM [BMS].[LocationDetails] LD LEFT OUTER JOIN [BMS].[BridgeDetails] bd ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT JOIN BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType LEFT JOIN BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype --LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.SolidorHallow LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND lm.Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END ELSE IF (@userType = 'D' and @hType is NULL) BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year',Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END 'Remarks' FROM [BMS].[LocationDetails] LD LEFT OUTER JOIN [BMS].[BridgeDetails] bd ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT JOIN BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType LEFT JOIN BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype --LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.SolidorHallow LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND lm.Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END ELSE BEGIN IF @hType = 'C' BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year',Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END 'Remarks' FROM [BMS].[LocationDetails] LD LEFT OUTER JOIN [BMS].[BridgeDetails] bd ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT JOIN BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType LEFT JOIN BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype --LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.SolidorHallow LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND lm.Circle = @hTypeVal AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END ELSE IF @hType = 'D' BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year',Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END 'Remarks' FROM [BMS].[LocationDetails] LD LEFT OUTER JOIN [BMS].[BridgeDetails] bd ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT JOIN BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType LEFT JOIN BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype --LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.SolidorHallow LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND lm.Division = @hTypeVal AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END IF @hType = 'W' BEGIN SELECT ld.[RoadCode] 'Road Code' , CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainage(km)' , ld.[LinkCode] 'Link Code',ld.Direction,ld.BridgeID as 'Bridge Code',bd.[Latitude],bd.[Longitude], BT.[Description] AS 'Type of bridge',BG.[Description] AS 'Function of Bridge',LD.YearofConstruction as 'Construction Year', bd.[Type1SpanNo] as 'No. of spans',bd.[BrdgLen] 'Over all bridge length',bd.[OverallDeckwidth] 'Overall deck width', st.Description as 'Skew type',convert(varchar, ld.DateofInspection, 103) as 'Date of Inventory',ld.[SurveyYear] 'Survey Year',Case when ld.Remarks IS NULL THEN Case When bd.Remarks IS NULL THEN hd.Remarks else bd.Remarks END else ld.Remarks END 'Remarks' FROM [BMS].[LocationDetails] LD LEFT OUTER JOIN [BMS].[BridgeDetails] bd ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT JOIN BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType LEFT JOIN BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype --LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.SolidorHallow LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) --AND ld.LinkCode IN (SELECT sdr.LinkCode FROM NM.LinkMaster sdr WHERE Circle IN (SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal)) AND lm.Circle IN (SELECT CircleCode FROM NM.Circle WHERE WingName= @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, BD.Chainage END END END GO ALTER PROCEDURE [dbo].[GetBridgeInventoryByFilter] --EXEC [dbo].[GetBridgeInventoryByFilter] 'SHIM',null,'BR:NH030:0000.100',0,1000 --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,1,NULL,NULL,NULL,'satya','H','D','RBD35' --EXEC [dbo].[GetBridgeInventoryByFilter] 'MDR_RBD01_004',NULL,NULL,4000,5000,'demogen','C',NULL,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] 'SH021',2,NULL,26000,38000,'div','D',NULL,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'dinesh',W,NULL,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'satya',NULL,H,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'krish',NULL,H,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'krish',NULL,H,NULL --EXEC [dbo].[GetBridgeInventoryByFilter] NULL,NULL,NULL,NULL,NULL,'krish',NULL,NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF (@userType = 'C' and @hType is NULL) BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd ,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge ,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF (@userType = 'D' and @hType is NULL) BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge ,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF (@userType = 'W' and @hType is NULL) BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd ,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE BEGIN IF @hType = 'C' BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd ,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'D' BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge ,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode' --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'W' BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd ,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'MLA' BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT sdr.Roadcode FROM [NM].[MLAConstituencyRoad] sdr Where MLACODE = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'MP' BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd ,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT sdr.Roadcode FROM [NM].[MPConstituencyRoad] sdr Where MPCODE = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE BEGIN SELECT [LocationId], ld.[RoadCode], ld.[LinkCode], BD.[Chainage], CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm', ld.[Direction], ld.[SurveyYear], [BridgeID],[BridgeID] as [Bridge_ID], ld.BridgeID as BridgeCode, --ld.[FunctionofBridge], ld.[YearofConstruction], ld.[Nameofnearbyplace], ld.[DateofInspection], [BridgeNameNo], [NameofRiverNallah], BD.[ContractorFirm], BD.[SupervisedConsultant], BD.[DesignConsultant], [State], [District], ld.[Circle], ld.[Division], ld.[SubDivision], ld.[Remarks], [CDNumber], bd.[BridgeDetailId] ,bd.[Latitude],bd.[Longitude] ,bd.[BridgeCode] ,bd.BrdgOvrTop,bd.SignBrdDmgd,bd.[Type1SpanNo],bd.[SpanArrgmnt] ,bd.[BrdgLen],bd.[DesignLoading],bd.[Repairsdonepriortoinventory],bd.ApprchSlabPrvd ,bd.[ApprchLength],bd.[ApprchRoadWidth],bd.[WearingCoatType] ,bd.[OverallDeckwidth],bd.[Carriagewaywidth],bd.DrngSpoutsPrvd ,bd.[NoofSpoutsPerSpan],bd.[AbutmentwallRailingtype],bd.[RailWidth] ,bd.[RailHeight],bd.[CCRailing],bd.FootpathonBridge,bd.[FootPathWidthLHS],bd.[FootPathWidthRHS],bd.KerbonBridge ,bd.[KerbWidthLHS],bd.[KerbWidthRHS],bd.ExpnJointExists ,bd.[ExpnJointType], bd.[Remarks], hd.[HydraulicDetailId], hd.[TypeofBedMaterial], hd.[IstheStreamerodable], hd.[SkewAngle] ,hd.[ToplevelofdeckRL], hd.[SoffitRLofdeck], hd.[HFL], hd.[Clearventsize], hd.[Clearverticaldistance], hd.[MinimumRLofbed] ,hd.[DesignVelocity], hd.[DesignDischarge], hd.[DesignScourLevelatmiddleRL], hd.[Catchmentarea], hd.BridgeGradient ,hd.[BridgeCategory], hd.[StreamCategory], hd.Whetherlocatedinbackwaterschemicalzone ,hd.[Crossingtherivertype], hd.Isthereanysignboardoverthebridge ,hd.[Isthereanyservicecrossingtheriverthroughth], hd.[LocationofService] ,hd.[Servicelineatonesideorbothsideofbridge] ,hd.Defectsinservicelines ,hd.leakagefromserviceline ,hd.Markingofpierlocations ,hd.MarkingofAbutmentlocations ,hd.[Typeofpierprotection], hd.[DateofInventory] ,hd.[Typeofabutprotection], hd.[Remarks], BG.[Description] AS 'FunctionofBridgeDescription' ,ld.[TypeoftheBridge],BT.[Description] AS 'BridgeTypeDescription', dl.Description DsgnLoadTypeDescription,wct.Description WearCoatTypeDescription,rt.Description RailTypeDescription,ft.Description FPTypeDescription,et.Description ExpjtTypeDescription, ppt.Description TypeofpierprotectionDescription,apt.Description TypeofabutprotectionDescription,sc.Description StreamCategoryDescription,bc.Description BridgeCategoryDescription, bmt.Description TypeofBedMaterialDescription,se.Description IstheStreamerodableDescription,scr.Description CrossingtherivertypeDescription,st.Description SkewAngleDescription, 'Approved' ApprovalStatus, bd.[SurveyYear] 'SurveyCode',st.Description as skewtype,BG.FuncBrdgType,BG.Description as functionofbridge,BT.BridgeType as typeoftheBridge --DevaNsr Added Cloumns ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END END END GO ALTER PROCEDURE [dbo].[GetBridgeInventoryDataByFilter] --exec [dbo].[GetBridgeInventoryDataByFilter] NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL --exec [dbo].[GetBridgeInventoryDataByFilter] NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL --exec [dbo].[GetBridgeInventoryDataByFilter] NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL --exec [dbo].[GetBridgeInventoryDataByFilter] NULL,NULL,NULL,NULL,NULL,'pranusha', 'W',NULL,NULL ( @roadCode VARCHAR(100)=NULL, @bridgeType VARCHAR(100) = NULL, @bridgeCode VARCHAR(100)=NULL, @StartChainage VARCHAR(100)=NULL, @EndChainage VARCHAR(100)=NULL, @user VARCHAR(50) = NULL, @userType VARCHAR(10) = NULL, @hType VARCHAR(10) = NULL, @hTypeVal VARCHAR(MAX) = NULL ) AS BEGIN IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL) BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF (@userType = 'D' and @hType is NULL) BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division IN (SELECT AreaName FROM [SSUM].[UserAreas] WHERE UserName = @user)) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF (@hType = 'C' OR @hType = 'W') BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Circle = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'D' BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND ld.LinkCode IN (SELECT LinkCode FROM NM.LinkMaster WHERE Division = @hTypeVal) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END ELSE IF @hType = 'MLA' BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode inner join NM.MLAConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MLACode = ISNULL(@hTypeVal,mcr.MLACode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY ld.RoadCode, Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial inner join NM.MLAConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MLACode = ISNULL(@hTypeVal,mcr.MLACode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY ld.RoadCode, Chainage END ELSE IF @hType = 'MP' BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY ld.RoadCode, Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY ld.RoadCode, bd.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode inner join NM.MPConstituencyRoad mcr on ld.RoadCode = mcr.RoadCode and ld.Chainage between mcr.StartChainage and mcr.EndChainage WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND mcr.MPCode = ISNULL(@hTypeVal,mcr.MPCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY ld.RoadCode, Chainage END ELSE IF @userType = 'H' BEGIN Select ld.RoadCode as 'Road Code' ,Chainage ,ld.LinkCode as 'Link Code' ,ld.Direction ,SurveyYear ,BridgeID as 'Bridge Code' ,CDNumber as 'CD Number' ,BridgeNameNo as 'Bridge Name' ,NameofRiverNallah as 'River Name' ,BG.[Description] as 'Function' ,BT.[Description] as 'Type' ,YearofConstruction as 'Construction Year' ,Nameofnearbyplace as 'Nearby Place' ,DateofInspection as 'Date of Inventory' ,ContractorFirm as 'Contractor' ,SupervisedConsultant as 'Supervise Consultant' ,DesignConsultant as 'Design Consultant' --,[State] -- ,District --,Circle --,Division --,SubDivision ,Ld.Remarks --,IsProcess -- ,OldCode from BMS.LocationDetails Ld Left Join BMS.LKPTBridgeType BT ON LD.TypeoftheBridge = BT.BridgeType Left Join BMS.LKPTFuncBrdg BG ON LD.FunctionofBridge = BG.FuncBrdgType INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND Chainage >=ISNULL(@StartChainage, Chainage) AND Chainage <=ISNULL(@EndChainage, Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select Latitude ,Longitude ,bd.BridgeCode as 'Bridge Code' ,bd.SurveyYear as 'Survey Year' ,BrdgOvrTop as 'Overtopped' ,SignBrdDmgd as 'Sign Board Damaged' ,Type1SpanNo as 'Spans Count' ,SpanArrgmnt as 'Spans Arrangement' ,dl.[Description] as 'Design Load' ,Repairsdonepriortoinventory as 'Last Repaires Done' ,ApprchSlabPrvd as 'Approach Slab Provided' ,bd.[ApprchLength] as 'Approach Slab Length' ,BrdgLen as 'Length' ,ApprchRoadWidth as 'Approach Roadway Width' ,wct.[Description] as 'Wearing coat' ,OverallDeckwidth as 'Deck Width' ,Carriagewaywidth as 'CW Width' ,DrngSpoutsPrvd as 'Drainage Spouts provided ' ,NoofSpoutsPerSpan as 'No. of Drainage Spouts' ,rt.[Description] as 'Abutment wall Railing' ,RailWidth as 'Abutment wall Width' ,RailHeight as 'Abutment wall Height' ,CCRailing as 'CC of RCC Post' ,FootpathonBridge as 'Footpath' ,ft.[Description] as'Solid or Hallow' ,FootPathWidthLHS as'FootPath Width LHS' ,FootPathWidthRHS as'FootPath Width RHS' ,KerbonBridge as 'Kerb on Bridge' ,KerbWidthLHS as 'Kerb Width LHS' ,KerbWidthRHS as 'Kerb Width RHS' ,ExpnJointExists as 'Expansion Joint' ,et.[Description] as 'Joints Types' ,bd.Remarks ,bd.DateofInspection ,bd.RoadCode ,bd.Direction ,bd.Chainage ,bd.CnstrctYear ,BT.Description AS BrdgType ,BG.Description AS BrdgFunc ,bd.RiverName ,bd.NearByPlace ,bd.ContractorFirm ,bd.SupervisedConsultant ,bd.DesignConsultant ,sc.Description AS StreamCategory ,bd.SkewAngle ,bd.BrdgGradient ,bd.HFLBedLevel ,bd.Clearverticaldistance ,SST.Description AS SuperStrctType ,ft.Description AS FootpathType ,DP.Description AS OrentofDrngPipe ,SL.Description AS LocofSrvc ,bd.Strctnum ,bd.MainSuperStrctType ,bd.Type2SpanNo ,bd.Type2SpanLength ,bd.Type3SpanNo ,bd.Type3SpanLength ,bd.TotalSpanNo ,bd.SkewValue ,dl.Description AS PresentLoading ,bd.SideSlopePitch ,bd.FloorPrtctPrvd ,bd.SrvcLineCrosBrdg ,bd.FloorPrtctType ,bd.NoSrvcDuctsFootpath ,bd.ExpnJointsNo ,bd.NoofSrvcLine ,bd.SrvcLineType ,bd.Type1SpanLength ,se.Description AS WaterWay ,bmt.Description AS BedMtrlType ,bd.SrvcLinePresentOn ,bd.SideSlopePitchType ,scr.Description AS Crossingtherivertype ,AWRT.Description AS AbutmentwallRailingtype ,dl.Description AS DesignLoading ,et.Description AS ExpnJointType ,wct.Description AS WearingCoatType ,MSST.Description AS MainSuperStrctType ,SLT.Description AS SrvcLineType ,PM.Description AS DrngePipeMaterial ,bd.PipesDiameter ,bd.SpacingBtwnPipes ,bd.HeadwallLength ,bd.PipeMtrl ,bd.PipesCount ,bd.CushionAbovePipe FROM [BMS].[BridgeDetails] bd LEFT OUTER JOIN [BMS].[LocationDetails] LD ON ld.BridgeID = bd.BridgeCode LEFT OUTER JOIN [BMS].[HydraulicDetails] hd ON ld.BridgeID = hd.BridgeCode LEFT OUTER JOIN BMS.LKPTBridgeType BT ON bd.BrdgType = BT.BridgeType LEFT OUTER JOIN BMS.LKPTFuncBrdg BG ON bd.BrdgFunc = BG.FuncBrdgType LEFT OUTER JOIN BMS.LKPTDsgnLoad dl ON dl.DsgnLoadType=bd.DesignLoading LEFT OUTER JOIN BMS.LKPTWearCoatType wct ON wct.WearCoatType=bd.WearingCoatType LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=bd.AbutmentwallRailingtype LEFT OUTER JOIN BMS.LKPTFPType ft ON ft.FPType=bd.FootpathType LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=bd.ExpnJointType LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=bd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=bd.BedMtrlType LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=bd.WaterWay LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on LD.LinkCode = lm.LinkCode --DevaNsr Added Lookups LEFT OUTER JOIN [BMS].[LKPTAbutWallrailType] AWRT WITH(NOLOCK) ON(AWRT.AbutWallrailType=bd.AbutmentwallRailingtype) LEFT OUTER JOIN [BMS].[LKPTSrvcLoc] SL ON SL.SrvcLocType = bd.LocofSrvc LEFT OUTER JOIN [BMS].[LKPTSupStructType] SST ON SST.SupStructType=bd.SuperStrctType LEFT OUTER JOIN bms.LKPTDrainPipe DP ON DP.DrainPipeType=bd.OrentofDrngPipe LEFT OUTER JOIN BMS.LKPTMainSupStructType MSST ON MSST.MainSupStructType=bd.MainSuperStrctType LEFT OUTER JOIN BMS.LKPTSrvcLineType SLT ON SLT.SrvcLineType=bd.SrvcLineType LEFT OUTER JOIN BMS.LKPTPipeMaterial PM ON PM.PipeMaterialType=bd.DrngePipeMaterial WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage Select BridgeCode as 'Bridge Code' ,hd.SurveyYear as 'Survey Year' ,bmt.[Description] as 'Bed Material' ,se.[Description] as 'Erodable stream' ,st.[Description] as 'Skew Angle' ,ToplevelofdeckRL as 'Top Level of deck RL' ,SoffitRLofdeck as 'Soffit of deck RL' ,HFL ,Clearventsize as 'Clear vent size' ,Clearverticaldistance as 'Vertical Distance' ,MinimumRLofbed as 'Minimum RL of Bed' ,DesignVelocity as 'Design Velocity' ,DesignDischarge as 'Design Discharge' ,DesignScourLevelatmiddleRL as 'Design Scour Level' ,Catchmentarea as 'Catchment Area' ,BridgeGradient as 'Gradient' ,bc.[Description] as 'Category' ,sc.[Description] as 'Stream Category' ,Whetherlocatedinbackwaterschemicalzone as 'Located in Backwater Zone' ,scr.[Description] as 'River Crossing' ,Isthereanysignboardoverthebridge as 'Sign Boards' ,Isthereanyservicecrossingtheriverthroughth as 'Service Crossing the river' ,LocationofService as 'Service Location' ,Servicelineatonesideorbothsideofbridge as 'Service Side' ,Defectsinservicelines as 'Defect' ,leakagefromserviceline as'Leakage' ,Markingofpierlocations as 'Pier Marking' ,MarkingofAbutmentlocations as 'Abutment Marking' ,ppt.[Description] as 'Pier Protection Type' ,DateofInventory ,hd.Remarks ,apt.[Description] as 'Abutment Protection Type' from BMS.HydraulicDetails hd inner join BMS.LocationDetails ld on hd.BridgeCode = ld.BridgeID LEFT OUTER JOIN BMS.LKPTPierPrtcnType ppt ON ppt.PierPrtcnTypeType=hd.Typeofpierprotection LEFT OUTER JOIN BMS.LKPTAbutPrtcnType apt ON apt.AbutPrtcnTypeType=hd.Typeofabutprotection LEFT OUTER JOIN BMS.LKPTStrmCatg sc ON sc.StrmCatgType=hd.StreamCategory LEFT OUTER JOIN BMS.LKPTBrdgCatg bc ON bc.BrdgCatgType=hd.BridgeCategory LEFT OUTER JOIN BMS.LKPTBedMaterType bmt ON bmt.BedMaterType=hd.TypeofBedMaterial LEFT OUTER JOIN BMS.LKPTStrmErod se ON se.StrmErodType=hd.IstheStreamerodable LEFT OUTER JOIN BMS.LKPTSrvCrsRvr scr ON scr.SrvCrsRvrType=hd.Crossingtherivertype LEFT OUTER JOIN BMS.LKPTSkewType st ON st.SkewType=hd.SkewAngle INNER JOIN NM.LinkMaster lm on Ld.LinkCode = lm.LinkCode WHERE ld.RoadCode = ISNULL(@roadCode,ld.RoadCode) AND TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge) AND BridgeID = ISNULL(@bridgeCode,BridgeID) AND LD.Chainage >=ISNULL(@StartChainage, ld.Chainage) AND LD.Chainage <=ISNULL(@EndChainage, ld.Chainage) ORDER BY lm.IsPilot desc,ld.RoadCode, ld.Chainage END END