Project

General

Profile

Data Services #1686 » 4)BearingCondition,AbutmentCondition,ReturnWall_WingWall,PierBearingCondition&PierCondition this 5Tables sps changes.sql

Sindhuja Kadari, 05/02/2025 07:03 PM

 
alter PROCEDURE [dbo].[GetBearingConditionByFilter]
--EXEC [dbo].[GetBearingConditionByFilter] NULL,NULL,'BI:MDR_PND01_002:0002.000','2',NULL,NULL,'satya', 'H',NULL,NULL,2019
--EXEC [dbo].[GetBearingConditionByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'pranusha', 'W',NULL,NULL,2019
--EXEC [dbo].[GetBearingConditionByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL,2019
--EXEC [dbo].[GetBearingConditionByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL,2019
(
@roadCode VARCHAR(100)=NULL,
@bridgeType VARCHAR(100) = NULL,
@bridgeCode VARCHAR(100)=NULL,
@season VARCHAR(50)=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
,@surveyYear VARCHAR(20) = NULL
)
AS
BEGIN
IF (@userType = 'H' and @hType IS NULL)
BEGIN
SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgBearRestCondid, BridgeCode
,hd.SurveyYear
,AbtmntNo
,CmprsBulgSides
,SurfaceCrck
,Rdlcrck
,ExsShrDfrmt
,CrckType
,CrckWidth
,CrckCnt
,AnchorBoltsDamaged
,NutLooseLocCnt
,bearingFreeMove
,CrcksInSmrstr
,SplDlmnCncrt
,ExpCrrdReinfrcmnt
,Anypartbroken
,DisldgmntBcklng
,PaintDamage
,LoosenutsBoltsCrackedweldetc
,BearingInspectedNtMsrd
,cs.Description as BearingCondSev
,ce.Description as BearingCondExt
,hd.Remarks


,DfrmtBearingShp
,FrgnMtrlExists
,RlrsRckrsPropPositn
,CrckInBearingsPdstl
,PdstlsInspectedNtMsrd
,SmRstrInspectedNtMsrd
,pcs.Description as PdstlsCondSev
,pce.Description as PdstlsCondExt
,scs.Description as SmRstrCondSev
,sce.Description as SmRstrCondExt
,CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus'
FROM [BMS].[BearingCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.CrckType=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.BearingCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.BearingCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON ce.CondExtType=hd.PdstlsCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON cs.CondSevType=hd.PdstlsCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=hd.SmRstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=hd.SmRstrCondSev
--LEFT OUTER JOIN BMS.LKPTBearType bt ON bt.BearType=hd.BearingType
-- LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE IF ((@userType = 'C' OR @userType = 'W') and @hType IS NULL)
BEGIN
SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgBearRestCondid, BridgeCode
,hd.SurveyYear
,AbtmntNo
,CmprsBulgSides
,SurfaceCrck
,Rdlcrck
,ExsShrDfrmt
,CrckType
,CrckWidth
,CrckCnt
,AnchorBoltsDamaged
,NutLooseLocCnt
,bearingFreeMove
,CrcksInSmrstr
,SplDlmnCncrt
,ExpCrrdReinfrcmnt
,Anypartbroken
,DisldgmntBcklng
,PaintDamage
,LoosenutsBoltsCrackedweldetc
,BearingInspectedNtMsrd
,cs.Description as BearingCondSev
,ce.Description as BearingCondExt
,hd.Remarks


,DfrmtBearingShp
,FrgnMtrlExists
,RlrsRckrsPropPositn
,CrckInBearingsPdstl
,PdstlsInspectedNtMsrd
,SmRstrInspectedNtMsrd
,pcs.Description as PdstlsCondSev
,pce.Description as PdstlsCondExt
,scs.Description as SmRstrCondSev
,sce.Description as SmRstrCondExt
,CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus'
FROM [BMS].[BearingCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.CrckType=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.BearingCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.BearingCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON ce.CondExtType=hd.PdstlsCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON cs.CondSevType=hd.PdstlsCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=hd.SmRstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=hd.SmRstrCondSev
--LEFT OUTER JOIN BMS.LKPTBearType bt ON bt.BearType=hd.BearingType
-- LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE IF (@userType = 'D' and @hType IS NULL)
BEGIN
SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgBearRestCondid, BridgeCode
,hd.SurveyYear
,AbtmntNo
,CmprsBulgSides
,SurfaceCrck
,Rdlcrck
,ExsShrDfrmt
,CrckType
,CrckWidth
,CrckCnt
,AnchorBoltsDamaged
,NutLooseLocCnt
,bearingFreeMove
,CrcksInSmrstr
,SplDlmnCncrt
,ExpCrrdReinfrcmnt
,Anypartbroken
,DisldgmntBcklng
,PaintDamage
,LoosenutsBoltsCrackedweldetc
,BearingInspectedNtMsrd
,cs.Description as BearingCondSev
,ce.Description as BearingCondExt
,hd.Remarks


,DfrmtBearingShp
,FrgnMtrlExists
,RlrsRckrsPropPositn
,CrckInBearingsPdstl
,PdstlsInspectedNtMsrd
,SmRstrInspectedNtMsrd
,pcs.Description as PdstlsCondSev
,pce.Description as PdstlsCondExt
,scs.Description as SmRstrCondSev
,sce.Description as SmRstrCondExt
,CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus'
FROM [BMS].[BearingCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.CrckType=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.BearingCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.BearingCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON ce.CondExtType=hd.PdstlsCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON cs.CondSevType=hd.PdstlsCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=hd.SmRstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=hd.SmRstrCondSev
--LEFT OUTER JOIN BMS.LKPTBearType bt ON bt.BearType=hd.BearingType
-- LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE
BEGIN
IF @hType = 'C'
BEGIN
SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgBearRestCondid, BridgeCode
,hd.SurveyYear
,AbtmntNo
,CmprsBulgSides
,SurfaceCrck
,Rdlcrck
,ExsShrDfrmt
,CrckType
,CrckWidth
,CrckCnt
,AnchorBoltsDamaged
,NutLooseLocCnt
,bearingFreeMove
,CrcksInSmrstr
,SplDlmnCncrt
,ExpCrrdReinfrcmnt
,Anypartbroken
,DisldgmntBcklng
,PaintDamage
,LoosenutsBoltsCrackedweldetc
,BearingInspectedNtMsrd
,cs.Description as BearingCondSev
,ce.Description as BearingCondExt
,hd.Remarks


,DfrmtBearingShp
,FrgnMtrlExists
,RlrsRckrsPropPositn
,CrckInBearingsPdstl
,PdstlsInspectedNtMsrd
,SmRstrInspectedNtMsrd
,pcs.Description as PdstlsCondSev
,pce.Description as PdstlsCondExt
,scs.Description as SmRstrCondSev
,sce.Description as SmRstrCondExt
,CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus'
FROM [BMS].[BearingCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.CrckType=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.BearingCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.BearingCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON ce.CondExtType=hd.PdstlsCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON cs.CondSevType=hd.PdstlsCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=hd.SmRstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=hd.SmRstrCondSev
--LEFT OUTER JOIN BMS.LKPTBearType bt ON bt.BearType=hd.BearingType
-- LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE IF @hType = 'D'
BEGIN
SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgBearRestCondid, BridgeCode
,hd.SurveyYear
,AbtmntNo
,CmprsBulgSides
,SurfaceCrck
,Rdlcrck
,ExsShrDfrmt
,CrckType
,CrckWidth
,CrckCnt
,AnchorBoltsDamaged
,NutLooseLocCnt
,bearingFreeMove
,CrcksInSmrstr
,SplDlmnCncrt
,ExpCrrdReinfrcmnt
,Anypartbroken
,DisldgmntBcklng
,PaintDamage
,LoosenutsBoltsCrackedweldetc
,BearingInspectedNtMsrd
,cs.Description as BearingCondSev
,ce.Description as BearingCondExt
,hd.Remarks


,DfrmtBearingShp
,FrgnMtrlExists
,RlrsRckrsPropPositn
,CrckInBearingsPdstl
,PdstlsInspectedNtMsrd
,SmRstrInspectedNtMsrd
,pcs.Description as PdstlsCondSev
,pce.Description as PdstlsCondExt
,scs.Description as SmRstrCondSev
,sce.Description as SmRstrCondExt
,CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus'
FROM [BMS].[BearingCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.CrckType=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.BearingCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.BearingCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON ce.CondExtType=hd.PdstlsCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON cs.CondSevType=hd.PdstlsCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=hd.SmRstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=hd.SmRstrCondSev
--LEFT OUTER JOIN BMS.LKPTBearType bt ON bt.BearType=hd.BearingType
-- LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE IF @hType = 'W'
BEGIN
SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgBearRestCondid, BridgeCode
,hd.SurveyYear
,AbtmntNo
,CmprsBulgSides
,SurfaceCrck
,Rdlcrck
,ExsShrDfrmt
,CrckType
,CrckWidth
,CrckCnt
,AnchorBoltsDamaged
,NutLooseLocCnt
,bearingFreeMove
,CrcksInSmrstr
,SplDlmnCncrt
,ExpCrrdReinfrcmnt
,Anypartbroken
,DisldgmntBcklng
,PaintDamage
,LoosenutsBoltsCrackedweldetc
,BearingInspectedNtMsrd
,cs.Description as BearingCondSev
,ce.Description as BearingCondExt
,hd.Remarks


,DfrmtBearingShp
,FrgnMtrlExists
,RlrsRckrsPropPositn
,CrckInBearingsPdstl
,PdstlsInspectedNtMsrd
,SmRstrInspectedNtMsrd
,pcs.Description as PdstlsCondSev
,pce.Description as PdstlsCondExt
,scs.Description as SmRstrCondSev
,sce.Description as SmRstrCondExt
,CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus'
FROM [BMS].[BearingCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.CrckType=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.BearingCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.BearingCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON ce.CondExtType=hd.PdstlsCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON cs.CondSevType=hd.PdstlsCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=hd.SmRstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=hd.SmRstrCondSev
--LEFT OUTER JOIN BMS.LKPTBearType bt ON bt.BearType=hd.BearingType
-- LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE IF @hType = 'MLA'
BEGIN
SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgBearRestCondid, BridgeCode
,hd.SurveyYear
,AbtmntNo
,CmprsBulgSides
,SurfaceCrck
,Rdlcrck
,ExsShrDfrmt
,CrckType
,CrckWidth
,CrckCnt
,AnchorBoltsDamaged
,NutLooseLocCnt
,bearingFreeMove
,CrcksInSmrstr
,SplDlmnCncrt
,ExpCrrdReinfrcmnt
,Anypartbroken
,DisldgmntBcklng
,PaintDamage
,LoosenutsBoltsCrackedweldetc
,BearingInspectedNtMsrd
,cs.Description as BearingCondSev
,ce.Description as BearingCondExt
,hd.Remarks


,DfrmtBearingShp
,FrgnMtrlExists
,RlrsRckrsPropPositn
,CrckInBearingsPdstl
,PdstlsInspectedNtMsrd
,SmRstrInspectedNtMsrd
,pcs.Description as PdstlsCondSev
,pce.Description as PdstlsCondExt
,scs.Description as SmRstrCondSev
,sce.Description as SmRstrCondExt
,CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus'
FROM [BMS].[BearingCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.CrckType=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.BearingCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.BearingCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON ce.CondExtType=hd.PdstlsCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON cs.CondSevType=hd.PdstlsCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=hd.SmRstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=hd.SmRstrCondSev
--LEFT OUTER JOIN BMS.LKPTBearType bt ON bt.BearType=hd.BearingType
-- LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE IF @hType = 'MP'
BEGIN
SELECT [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgBearRestCondid, BridgeCode
,hd.SurveyYear
,AbtmntNo
,CmprsBulgSides
,SurfaceCrck
,Rdlcrck
,ExsShrDfrmt
,CrckType
,CrckWidth
,CrckCnt
,AnchorBoltsDamaged
,NutLooseLocCnt
,bearingFreeMove
,CrcksInSmrstr
,SplDlmnCncrt
,ExpCrrdReinfrcmnt
,Anypartbroken
,DisldgmntBcklng
,PaintDamage
,LoosenutsBoltsCrackedweldetc
,BearingInspectedNtMsrd
,cs.Description as BearingCondSev
,ce.Description as BearingCondExt
,hd.Remarks


,DfrmtBearingShp
,FrgnMtrlExists
,RlrsRckrsPropPositn
,CrckInBearingsPdstl
,PdstlsInspectedNtMsrd
,SmRstrInspectedNtMsrd
,pcs.Description as PdstlsCondSev
,pce.Description as PdstlsCondExt
,scs.Description as SmRstrCondSev
,sce.Description as SmRstrCondExt
,CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus'
FROM [BMS].[BearingCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.CrckType=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.BearingCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.BearingCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON ce.CondExtType=hd.PdstlsCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON cs.CondSevType=hd.PdstlsCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=hd.SmRstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=hd.SmRstrCondSev
--LEFT OUTER JOIN BMS.LKPTBearType bt ON bt.BearType=hd.BearingType
-- LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
END
END
GO
alter PROCEDURE [dbo].[GetCrossGirderConditionByFilter]
--EXEC [dbo].[GetCrossGirderConditionByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL,2019
--EXEC [dbo].[GetCrossGirderConditionByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'pranusha', 'w',NULL,NULL,2019
--EXEC [dbo].[GetCrossGirderConditionByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL,2019
--EXEC [dbo].[GetCrossGirderConditionByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL,2019
(
@roadCode VARCHAR(100)=NULL,
@bridgeType VARCHAR(100) = NULL,
@bridgeCode VARCHAR(100)=NULL,
@season VARCHAR(50)=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,
@surveyYear VARCHAR(20) = NULL
)
AS
BEGIN
IF (@userType = 'H' and @hType is NULL)
BEGIN
select [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],bd.DateofInspection,
BrdgSupStrCrsGrdrCondid, hd.BridgeCode, (CASE WHEN dsd.SurveyYear IS NOT NULL THEN dsd.SurveyYear when dsd.SurveyYear is NULL THEN dsc.SurveyYear end) as 'SurveyID'
,bd.Type1SpanNo
, (CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end) as 'SpanNo',
(Case WHEN JC.AbutmentPierNumber IS NOT NULL THEN JC.AbutmentPierNumber WHEN JC.AbutmentPierNumber IS NULL THEN BC.AbtmntNo END) AS 'Abutment Pier No' ,
lkptSev.[Description] as Surfaceconditionseverity,lkptExt.[Description]+'('+lkptExt.Remarks+')' as SurfaceConditionExtent,
lkptSevDSC.[Description] as SlabConditionSeverity,lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as SlabconditionExtent,
lkptSevGC.[Description] as GirderConditionSeverity,lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as GirderConditionExtent,
lkptSevJC.[Description] as JointConditionSeverity,lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as JointConditionExtent,
lkptSevBC.[Description] as BearingConditionSeverity,lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as BearingConditionExtent,
hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
, CASE WHEN dsd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus',dsd.Season as 'seasonID' ,S.[Description] as Season
FROM [BMS].[LocationDetails] ld
LEFT JOIN BMS.BridgeDetails bd on ld.BridgeID = bd.BridgeCode
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON ld.BridgeID =DSD.Bridgecode
LEFT OUTER JOIN BMS.CrossGirderCondition hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = dsd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = DSC.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsc.SlabConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and JC.Season = dsd.Season and JC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and GC.SpanNo = dsd.SpanNo and GC.Season = dsd.Season and GC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and BC.SurveyYear = dsd.SurveyYear --and BC.Season = dsd.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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,ld.TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND dsd.Season = ISNULL(@season,dsd.Season)
AND dsd.SurveyYear=ISNULL(@surveyYear,dsd.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,(CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end))
END
ELSE IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL)
BEGIN
select [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],bd.DateofInspection,
BrdgSupStrCrsGrdrCondid, hd.BridgeCode, (CASE WHEN dsd.SurveyYear IS NOT NULL THEN dsd.SurveyYear when dsd.SurveyYear is NULL THEN dsc.SurveyYear end) as 'SurveyID'
,bd.Type1SpanNo
, (CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end) as 'SpanNo',
(Case WHEN JC.AbutmentPierNumber IS NOT NULL THEN JC.AbutmentPierNumber WHEN JC.AbutmentPierNumber IS NULL THEN BC.AbtmntNo END) AS 'Abutment Pier No' ,
lkptSev.[Description] as Surfaceconditionseverity,lkptExt.[Description]+'('+lkptExt.Remarks+')' as SurfaceConditionExtent,
lkptSevDSC.[Description] as SlabConditionSeverity,lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as SlabconditionExtent,
lkptSevGC.[Description] as GirderConditionSeverity,lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as GirderConditionExtent,
lkptSevJC.[Description] as JointConditionSeverity,lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as JointConditionExtent,
lkptSevBC.[Description] as BearingConditionSeverity,lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as BearingConditionExtent,
hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
, CASE WHEN dsd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus',dsd.Season as 'seasonID' ,S.[Description] as Season
FROM [BMS].[LocationDetails] ld
LEFT JOIN BMS.BridgeDetails bd on ld.BridgeID = bd.BridgeCode
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON ld.BridgeID =DSD.Bridgecode
LEFT OUTER JOIN BMS.CrossGirderCondition hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = dsd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = DSC.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsc.SlabConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and JC.Season = dsd.Season and JC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and GC.SpanNo = dsd.SpanNo and GC.Season = dsd.Season and GC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and BC.SurveyYear = dsd.SurveyYear-- and BC.Season = dsd.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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,ld.TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND dsd.Season = ISNULL(@season,dsd.Season)
AND dsd.SurveyYear=ISNULL(@surveyYear,dsd.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,(CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end))
END
ELSE IF (@userType = 'D' and @hType is NULL)
BEGIN
select [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],bd.DateofInspection,
BrdgSupStrCrsGrdrCondid, hd.BridgeCode, (CASE WHEN dsd.SurveyYear IS NOT NULL THEN dsd.SurveyYear when dsd.SurveyYear is NULL THEN dsc.SurveyYear end) as 'SurveyID'
,bd.Type1SpanNo
, (CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end) as 'SpanNo',(Case WHEN JC.AbutmentPierNumber IS NOT NULL THEN JC.AbutmentPierNumber WHEN JC.AbutmentPierNumber IS NULL THEN BC.AbtmntNo END) AS 'Abutment Pi
er No' ,
lkptSev.[Description] as Surfaceconditionseverity,lkptExt.[Description]+'('+lkptExt.Remarks+')' as SurfaceConditionExtent,
lkptSevDSC.[Description] as SlabConditionSeverity,lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as SlabconditionExtent,
lkptSevGC.[Description] as GirderConditionSeverity,lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as GirderConditionExtent,
lkptSevJC.[Description] as JointConditionSeverity,lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as JointConditionExtent,
lkptSevBC.[Description] as BearingConditionSeverity,lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as BearingConditionExtent,
hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
, CASE WHEN dsd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus',dsd.Season as 'seasonID' ,S.[Description] as Season
FROM [BMS].[LocationDetails] ld
LEFT JOIN BMS.BridgeDetails bd on ld.BridgeID = bd.BridgeCode
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON ld.BridgeID =DSD.Bridgecode
LEFT OUTER JOIN BMS.CrossGirderCondition hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = dsd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = DSC.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsc.SlabConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and JC.Season = dsd.Season and JC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and GC.SpanNo = dsd.SpanNo and GC.Season = dsd.Season and GC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and BC.SurveyYear = dsd.SurveyYear-- and BC.Season = dsd.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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,ld.TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID)
AND dsd.Season = ISNULL(@season, dsd.Season)
AND dsd.SurveyYear = ISNULL(@surveyYear, dsd.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,(CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end))
END
-- ELSE IF (@userType = 'W' and @hType is NULL)
-- BEGIN
-- select [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
-- ,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],DateofInspection,
--BrdgSupStrCrsGrdrCondid, hd.BridgeCode, (CASE WHEN dsd.SurveyYear IS NOT NULL THEN dsd.SurveyYear when dsd.SurveyYear is NULL THEN dsc.SurveyYear end) as 'SurveyID'
--,bd.Type1SpanNo
--, (CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end) as 'SpanNo',
--(Case WHEN JC.AbutmentPierNumber IS NOT NULL THEN JC.AbutmentPierNumber WHEN JC.AbutmentPierNumber IS NULL THEN BC.AbtmntNo END) AS 'Abutment Pier No' ,
--lkptSev.[Description] as Surfaceconditionseverity,lkptExt.[Description]+'('+lkptExt.Remarks+')' as SurfaceConditionExtent,
--lkptSevDSC.[Description] as SlabConditionSeverity,lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as SlabconditionExtent,
--lkptSevGC.[Description] as GirderConditionSeverity,lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as GirderConditionExtent,
--lkptSevJC.[Description] as JointConditionSeverity,lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as JointConditionExtent,
--lkptSevBC.[Description] as BearingConditionSeverity,lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as BearingConditionExtent,
-- hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
--hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
--hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
--ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
-- , CASE WHEN dsd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus',dsd.Season as 'seasonID' ,S.[Description] as Season
-- FROM [BMS].[LocationDetails] ld
-- LEFT JOIN BMS.BridgeDetails bd on ld.BridgeID = bd.BridgeCode
-- LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON ld.BridgeID =DSD.Bridgecode
-- LEFT OUTER JOIN BMS.CrossGirderCondition hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = dsd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
-- LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
-- LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
-- LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = DSC.Season and dsd.SurveyYear = DSC.SurveyYear
-- LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
-- LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsc.SlabConditionExtent=lkptExtDSC.ExtentCode
-- LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and JC.Season = dsd.Season and JC.SurveyYear = dsd.SurveyYear
--LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
--LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
-- LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and GC.SpanNo = dsd.SpanNo and GC.Season = dsd.Season and GC.SurveyYear = dsd.SurveyYear
--LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
--LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
-- LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and BC.Season = dsd.Season and BC.SurveyYear = dsd.SurveyYear
--LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingConditionExtent= lkptExtBC.ExtentCode
--LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingConditionSeverity=lkptSevBC.SeverityCode
-- LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
-- LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
-- LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
-- LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
-- LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
-- 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,ld.TypeoftheBridge)
-- AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID)
-- AND dsd.Season = ISNULL(@season, dsd.Season)
-- AND dsd.SurveyYear = ISNULL(@surveyYear, dsd.SurveyYear)
-- END
ELSE
BEGIN
IF @hType = 'C'
BEGIN
select [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],bd.DateofInspection,
BrdgSupStrCrsGrdrCondid, hd.BridgeCode, (CASE WHEN dsd.SurveyYear IS NOT NULL THEN dsd.SurveyYear when dsd.SurveyYear is NULL THEN dsc.SurveyYear end) as 'SurveyID'
,bd.Type1SpanNo
, (CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end) as 'SpanNo',
(Case WHEN JC.AbutmentPierNumber IS NOT NULL THEN JC.AbutmentPierNumber WHEN JC.AbutmentPierNumber IS NULL THEN BC.AbtmntNo END) AS 'Abutment Pier No' ,
lkptSev.[Description] as Surfaceconditionseverity,lkptExt.[Description]+'('+lkptExt.Remarks+')' as SurfaceConditionExtent,
lkptSevDSC.[Description] as SlabConditionSeverity,lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as SlabconditionExtent,
lkptSevGC.[Description] as GirderConditionSeverity,lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as GirderConditionExtent,
lkptSevJC.[Description] as JointConditionSeverity,lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as JointConditionExtent,
lkptSevBC.[Description] as BearingConditionSeverity,lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as BearingConditionExtent,
hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
, CASE WHEN dsd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus',dsd.Season as 'seasonID' ,S.[Description] as Season
FROM [BMS].[LocationDetails] ld
LEFT JOIN BMS.BridgeDetails bd on ld.BridgeID = bd.BridgeCode
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON ld.BridgeID =DSD.Bridgecode
LEFT OUTER JOIN BMS.CrossGirderCondition hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = dsd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = DSC.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsc.SlabConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and JC.Season = dsd.Season and JC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and GC.SpanNo = dsd.SpanNo and GC.Season = dsd.Season and GC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and BC.SurveyYear = dsd.SurveyYear-- and BC.Season = dsd.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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,ld.TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND dsd.Season = ISNULL(@season,dsd.Season)
AND dsd.SurveyYear=ISNULL(@surveyYear,dsd.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,(CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end))
END
ELSE IF @hType = 'D'
BEGIN
select [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],bd.DateofInspection,
BrdgSupStrCrsGrdrCondid, hd.BridgeCode, (CASE WHEN dsd.SurveyYear IS NOT NULL THEN dsd.SurveyYear when dsd.SurveyYear is NULL THEN dsc.SurveyYear end) as 'SurveyID'
,bd.Type1SpanNo
, (CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end) as 'SpanNo',
(Case WHEN JC.AbutmentPierNumber IS NOT NULL THEN JC.AbutmentPierNumber WHEN JC.AbutmentPierNumber IS NULL THEN BC.AbtmntNo END) AS 'Abutment Pier No' ,
lkptSev.[Description] as Surfaceconditionseverity,lkptExt.[Description]+'('+lkptExt.Remarks+')' as SurfaceConditionExtent,
lkptSevDSC.[Description] as SlabConditionSeverity,lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as SlabconditionExtent,
lkptSevGC.[Description] as GirderConditionSeverity,lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as GirderConditionExtent,
lkptSevJC.[Description] as JointConditionSeverity,lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as JointConditionExtent,
lkptSevBC.[Description] as BearingConditionSeverity,lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as BearingConditionExtent,
hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
, CASE WHEN dsd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus',dsd.Season as 'seasonID' ,S.[Description] as Season
FROM [BMS].[LocationDetails] ld
LEFT JOIN BMS.BridgeDetails bd on ld.BridgeID = bd.BridgeCode
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON ld.BridgeID =DSD.Bridgecode
LEFT OUTER JOIN BMS.CrossGirderCondition hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = dsd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = DSC.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsc.SlabConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and JC.Season = dsd.Season and JC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and GC.SpanNo = dsd.SpanNo and GC.Season = dsd.Season and GC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and BC.SurveyYear = dsd.SurveyYear-- and BC.Season = dsd.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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,ld.TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID)
AND dsd.Season = ISNULL(@season, dsd.Season)
AND dsd.SurveyYear = ISNULL(@surveyYear, dsd.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,(CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end))
END
ELSE IF @hType = 'W'
BEGIN
select [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],bd.DateofInspection,
BrdgSupStrCrsGrdrCondid, hd.BridgeCode, (CASE WHEN dsd.SurveyYear IS NOT NULL THEN dsd.SurveyYear when dsd.SurveyYear is NULL THEN dsc.SurveyYear end) as 'SurveyID'
,bd.Type1SpanNo
, (CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end) as 'SpanNo',
(Case WHEN JC.AbutmentPierNumber IS NOT NULL THEN JC.AbutmentPierNumber WHEN JC.AbutmentPierNumber IS NULL THEN BC.AbtmntNo END) AS 'Abutment Pier No' ,
lkptSev.[Description] as Surfaceconditionseverity,lkptExt.[Description]+'('+lkptExt.Remarks+')' as SurfaceConditionExtent,
lkptSevDSC.[Description] as SlabConditionSeverity,lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as SlabconditionExtent,
lkptSevGC.[Description] as GirderConditionSeverity,lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as GirderConditionExtent,
lkptSevJC.[Description] as JointConditionSeverity,lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as JointConditionExtent,
lkptSevBC.[Description] as BearingConditionSeverity,lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as BearingConditionExtent,
hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
, CASE WHEN dsd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus',dsd.Season as 'seasonID' ,S.[Description] as Season
FROM [BMS].[LocationDetails] ld
LEFT JOIN BMS.BridgeDetails bd on ld.BridgeID = bd.BridgeCode
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON ld.BridgeID =DSD.Bridgecode
LEFT OUTER JOIN BMS.CrossGirderCondition hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = dsd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = DSC.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsc.SlabConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and JC.Season = dsd.Season and JC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and GC.SpanNo = dsd.SpanNo and GC.Season = dsd.Season and GC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and BC.SurveyYear = dsd.SurveyYear-- and BC.Season = dsd.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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 TypeoftheBridge = ISNULL(@bridgeType,ld.TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID)
AND dsd.Season = ISNULL(@season, dsd.Season)
AND dsd.SurveyYear = ISNULL(@surveyYear, dsd.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,(CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end))
END
ELSE IF @hType = 'MLA'
BEGIN
select [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],bd.DateofInspection,
BrdgSupStrCrsGrdrCondid, hd.BridgeCode, (CASE WHEN dsd.SurveyYear IS NOT NULL THEN dsd.SurveyYear when dsd.SurveyYear is NULL THEN dsc.SurveyYear end) as 'SurveyID'
,bd.Type1SpanNo
, (CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end) as 'SpanNo',
(Case WHEN JC.AbutmentPierNumber IS NOT NULL THEN JC.AbutmentPierNumber WHEN JC.AbutmentPierNumber IS NULL THEN BC.AbtmntNo END) AS 'Abutment Pier No' ,
lkptSev.[Description] as Surfaceconditionseverity,lkptExt.[Description]+'('+lkptExt.Remarks+')' as SurfaceConditionExtent,
lkptSevDSC.[Description] as SlabConditionSeverity,lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as SlabconditionExtent,
lkptSevGC.[Description] as GirderConditionSeverity,lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as GirderConditionExtent,
lkptSevJC.[Description] as JointConditionSeverity,lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as JointConditionExtent,
lkptSevBC.[Description] as BearingConditionSeverity,lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as BearingConditionExtent,
hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
, CASE WHEN dsd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus',dsd.Season as 'seasonID' ,S.[Description] as Season
FROM [BMS].[LocationDetails] ld
LEFT JOIN BMS.BridgeDetails bd on ld.BridgeID = bd.BridgeCode
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON ld.BridgeID =DSD.Bridgecode
LEFT OUTER JOIN BMS.CrossGirderCondition hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = dsd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = DSC.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsc.SlabConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and JC.Season = dsd.Season and JC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and GC.SpanNo = dsd.SpanNo and GC.Season = dsd.Season and GC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and BC.SurveyYear = dsd.SurveyYear-- and BC.Season = dsd.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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,ld.TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID)
AND dsd.Season = ISNULL(@season, dsd.Season)
AND dsd.SurveyYear = ISNULL(@surveyYear, dsd.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,(CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end))
END
ELSE IF @hType = 'MP' BEGIN
select [LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(ld.Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],bd.DateofInspection,
BrdgSupStrCrsGrdrCondid, hd.BridgeCode, (CASE WHEN dsd.SurveyYear IS NOT NULL THEN dsd.SurveyYear when dsd.SurveyYear is NULL THEN dsc.SurveyYear end) as 'SurveyID'
,bd.Type1SpanNo
, (CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end) as 'SpanNo',(Case WHEN JC.AbutmentPierNumber IS NOT NULL THEN JC.AbutmentPierNumber WHEN JC.AbutmentPierNumber IS NULL THEN BC.AbtmntNo END) AS 'Abutment Pi
er No' ,
lkptSev.[Description] as Surfaceconditionseverity,lkptExt.[Description]+'('+lkptExt.Remarks+')' as SurfaceConditionExtent,
lkptSevDSC.[Description] as SlabConditionSeverity,lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as SlabconditionExtent,
lkptSevGC.[Description] as GirderConditionSeverity,lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as GirderConditionExtent,
lkptSevJC.[Description] as JointConditionSeverity,lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as JointConditionExtent,
lkptSevBC.[Description] as BearingConditionSeverity,lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as BearingConditionExtent,
hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
, CASE WHEN dsd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus',dsd.Season as 'seasonID' ,S.[Description] as Season
FROM [BMS].[LocationDetails] ld
LEFT JOIN BMS.BridgeDetails bd on ld.BridgeID = bd.BridgeCode
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON ld.BridgeID =DSD.Bridgecode
LEFT OUTER JOIN BMS.CrossGirderCondition hd ON hd.BridgeCode = ld.BridgeID and hd.SpanNo = dsd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = DSC.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsc.SlabConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and JC.Season = dsd.Season and JC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and GC.SpanNo = dsd.SpanNo and GC.Season = dsd.Season and GC.SurveyYear = dsd.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and BC.SurveyYear = dsd.SurveyYear-- and BC.Season = dsd.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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,ld.TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode, ld.BridgeID)
AND dsd.Season = ISNULL(@season, dsd.Season)
AND dsd.SurveyYear = ISNULL(@surveyYear, dsd.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,(CASE WHEN dsd.SpanNo IS NOT NULL THEN dsd.SpanNo when dsd.SpanNo is NULL THEN dsc.SpanNo end))
END
END
END
GO
alter PROCEDURE [dbo].[GetspanConditionsByFilter]
--EXEC [dbo].[GetCrossGirderConditionByFilter] 'NH030'
--EXEC [dbo].[GetCrossGirderConditionByFilter] NULL,NULL,NULL,NULL,NULL,'krish', NULL,NULL,NULL
--exec [dbo].[GetspanConditionsByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL,NULL
--exec [dbo].[GetspanConditionsByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'pranusha', 'W',NULL,NULL,NULL
--exec [dbo].[GetspanConditionsByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL,NULL
--exec [dbo].[GetspanConditionsByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL,NULL
(
@roadCode VARCHAR(100)=NULL,
@bridgeType VARCHAR(100) = NULL,
@bridgeCode VARCHAR(100)=NULL,
@season VARCHAR(50)=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,
@surveyYear VARCHAR(20) = NULL
)
AS
BEGIN
IF (@userType = 'H' and @hType is NULL)
BEGIN
select BridgeCode as 'Bridge Code'
,SurveyID as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,LengthofCrack as 'Length of cracks (m)'
,Noofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks 'Location of cracks'
,Spalling as 'Spalling'
,NoofBarsExposed as 'No of bars exposed'
,CorrosionofReinforcement as 'Corrosion of Reinforcement (sqm)'
,LocationofCorrosion as'Location of corrosion'
,PoorConcrete 'Poor concrete'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,cgc.Remarks
,S.[Description] as 'Season'
from BMS.CrossGirderCondition cgc
inner join BMS.LocationDetails ld on cgc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON cgc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=cgc.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=cgc.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=cgc.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=cgc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt


,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,dsc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,dst.[Description] as 'Deck surface material type'
,st.[Description] as 'Deck surface cracking type'
,CrackingCond as 'Cracking Condition'
,AreaofFineCracking as 'Area of fine cracking'
,AreaofWideCracking as 'Area of wide cracking'
,areaofsurfacecrack as 'Area of surface cracking'
,Potholes
,Ravelling
,totalareaofdepression as 'Total area of depression'
,CorrugationsRipples as 'Corrugation ripples'
,Spalling
,ReinforcementExposed as 'Reinforcement exposed'
,PoorConcrete as 'Poor concrete'
,fp.[Description] as 'Footpath type'
,NatureOfDamage as 'Nature of damage'
,totalnumberofductsblocked as 'Total number of ducts blocked'
,FootpathDamagedPortion as 'footpath damaged portion'
,percentageoffootpathdamaged as 'percentage of footpath damaged'
,pondingofwater as 'ponding of water'
,cs.[Description] as 'Surface Condition Severity'
,ce.[Description] as 'Surface Condition Extent'
,dsc.Remarks
,S.[Description] as Season
from BMS.DeckSurfaceCondition dsc
INNER JOIN [BMS].[LocationDetails] ld ON dsc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=dsc.SurfaceConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=dsc.SurfaceConditionSeverity
LEFT OUTER JOIN BMS.LKPTSurfType st ON st.SurfType= dsc.DeckSurfaceCrackingType
LEFT OUTER JOIN bms.LKPTFPType ft ON ft.FPType=dsc.FootpathType
LEFT OUTER JOIN BMS.LKPTDeckSurfMaterType dst ON dst.DeckSurfMaterType= dsc.DeckSurfaceMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsc.Season
LEFT OUTER JOIN BMS.LKPTFPType fp on dsc.FootpathType = fp.FPType
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,drn.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,NoofspoutsfilledwithdebrisNum as 'No of spouts filled with debris'
,CorrosionofGrills as 'Corrosion of grills'
,NospoutswithoutgrillsNum as 'No of spouts without grills'
,PropercrossslopeinSuperStructure as 'Proper cross slope in super sturcture'
,OrientationofDrainagepipe as 'Orientation of drainage pipe'
,PipeMaterial as 'Pipe material'
,LeachingSpallingNearPipe as 'Leaching or spalling near pipe'
,noofspoutsendedatsoffit as 'No of spouts ended at soffit'
,Noofspoutpipesmissing as 'No of spout pipes missing'
,Pipeprojectionbelowsoffit as 'Pipe projection below soffit'
,collectionpitatdrainage as 'Collection pit at drainage'
,drn.Remarks
,S.[Description] as 'Season'
from BMS.DrainSpoutCondition drn
INNER JOIN [BMS].[LocationDetails] ld ON drn.BridgeCode = ld.BridgeID
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=drn.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,rc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,rt.[Description] as 'Railing type'
,Damagetoouter as 'Damage to outer'
,Looseordamagedfixings as 'Loose or damaged fixings'
,DeteriarationofpaintSqm as 'Deterioration of paint (Sqm)'
,NumberofpipesmissingNum as 'Number of pipes missing'
,Totallengthofmissingpipes as 'Total length of missing pipes'
,NumberofpostsmissingNum as 'Number of posts missing'
,Cracks
,DetailsofDamagedRailing as 'Details of Damaged Railing'
,DamagedCrashBarrier as 'Damaged Crash Barrier'
,Spalling
,LengthRequiredtotalreplacement as 'Length Required total replacement'
,cs.[Description] as 'Railing Condition Severity'
,ce.[Description] as 'Railing Condition Extent'
,rc.Remarks
,S.[Description] as 'Season'
from BMS.RailingCondition rc
INNER JOIN [BMS].[LocationDetails] ld ON rc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=rc.RailingConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=rc.RailingConditionSeverity
LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=rc.RailingType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=rc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,jc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment or Pier No'
,Et.[Description] as 'Expansion Joint type'
,Concretedamageatexpansionjoint as 'Concrete damage at expansion joint'
,Damageorcorrosiontometalparts as 'Damage or corrosion to metal parts'
,Damagetorubberwaterseals as 'Damage to rubber water seals'
,LooseorDamagedfixtures as 'Loose or damaged fixtures'
,Signsofleakageunderneaththedeck as 'Signs of leakage underneath the deck'
,DebrisorVegetationinjoint as 'Debris or vegetation in joint'
,CheckforProperVerticalAlignment as 'Check for proper vertical alignment'
,soundatexpjoint as 'Sound at joint'
,cs.[Description]as 'Joint Condition Severity'
,ce.[Description] as 'Joint Condition Extent'
,jc.Remarks
,S.[Description] as 'Season'
from BMS.JointCondition jc
INNER JOIN [BMS].[LocationDetails] ld ON jc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=jc.JointConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=jc.JointConditionSeverity
LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=jc.ExpansionJointType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=jc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt


,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,slb.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Types of Crack'
,Lengthofcrack as 'Length of crack (m)'
,Numberofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,NumberofSpalls as 'No of Spalls'
,Spalling
,DepthOfEachSpall as 'Depth of each spall'
,Noofbarsexposed as 'No of bars exposed'
,Corrosionofreinforcement as 'Corrosion or reinforcement'
,PercentageofCorrosion as 'Corrosion (%)'
,PitCorrosion as 'Pit corrosion'
,Locationofcorrosionofreinforcement as 'Location of corrosion of reinforcement'
,PoorConcrete as 'Poor concrete'
,Floreseffectedlocationno as 'Flores Effected Location No'
,DeflectionVisible as 'Deflection visible'
,Excessivevibrationisobserved as 'Excessive vibration observed'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,hitslabbyhammer as 'Sound due to hit slab by hammer'
,pondingofwater as 'Ponding of water'
,locationsofspotswhereconcretediscoloured as 'Locations where concrete discoloured'
,AnchorForCrossPreStressing as 'Anchor for cross prestressing'
,NumberofDamagedAnchorinaSpan as 'No of damaged anchors in a span'
,DescriptionofDamage as 'Damage description'
,DegreeofCorrosionoftheAnchorageend as 'Degree of corrosion of the anchorageend'
,DescriptionofDamageofDucts as 'Description of Damage of Ducts'
,NumberofLooseStrands as 'No of Loose strands'
,TotalNumberofStrandsateachAnchorage as 'Total no of strands at each anchorage'
,ElementinspectedbutnotMeasured as 'Element inspected but not measured'
,VerticalDeflectionofContilevertip as 'Vertical deflection of contilevertip'
,ModerateDeflection as 'Moderate deflection'
,ExcessiveDeflection as 'Excessive deflection'
,ConditionofJointBetweenDeckSlabandGirders as 'Condition of joint between deckslab and girders'
,dripcourseatedgofslab as 'Drip course at edge of slab'
,cs.[Description] as 'Slab Condition Severity'
,ce.[Description] as 'Slab Condition Extent'
,slb.Remarks
,S.[Description] as 'Season'
from BMS.DeckSlabCondition slb
INNER JOIN [BMS].[LocationDetails] ld ON slb.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=slb.SlabconditionExtent
LEFT OUTER JOIN bms.LKPTCrkType ct ON ct.CrackType=slb.Typeofcracks
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=slb.SlabConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=slb.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=slb.ConditionofPainting
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=slb.ConditionofSteelMembers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=slb.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,gc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,Lengthofcrack as 'Length of crack (m)'
,NumberofcracksNum as 'Number of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,Spalling as 'Spalling / Rusting (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,PoorConcrete as 'Poor Concrete / Steel (Sqm)'
,DeflectionVisible as 'Deflection Visible'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel numbers'
,AnchorForCrossPreStressing as 'Anchor For Cross Pre Stressing'
,NoOfanchordamagedinspan as 'Number of Damaged Anchor in a Span'
,DegreeofCorrosionatAnchorage as 'Degree of Corrosion of the Anchorage end'
,DescofDmgofDucts as 'Description for Damage of Ducts'
,NumberofLooseStrands as 'Number of Loose Strands'
,NoOfstrandsatanchorage as 'Number of Strands at each Anchorage'
,Inspectedbutnotmeasured as 'Element inspected but not Measured'
,SpallsinaSpan as 'Spalls in a Span'
,NumberOfSpallLocation as 'Number Of Spall Location'
,numberofBarsExposedandCorroded as 'number of Bars Exposed and Corroded'
,PercentageOfCorrosion as 'Percentage Of Corrosion '
,Floreseffectedlocationno as 'Number of locations in a span effected by efflorescence, dampness and leakage'
,cs.[Description] as 'Girder condition Severity'
,ce.[Description] as 'Girder condition Extent'
,gc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.GirderCondition gc
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON gc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON gc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=gc.GirderConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=gc.GirderConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=gc.conditionofconnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=gc.conditionofpaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=gc.conditionofsteelnumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=gc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,fc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment/Pier Number'
,AM.[Description] as 'Foundation Material Type'
,FoundationScourobserved as 'Foundation Scour observed'
,ScourDepth as 'Scour Depth (m)'
,FoundationSettlementisobserved as 'Foundation Settlement is observed'
,settlementobserved as 'settlement observed (m)'
,Cracking as 'Cracking (m)'
,Spalling as 'Spalling (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,Bulging as 'Bulging (Sqm)'
,PoorPointing as 'Poor Pointing (Sqm)'
,DeteriorationofBricksorStones as 'Deterioration of Bricks or Stones (Sqm)'
,damagedbedprotection as 'Observed Dislodgement and damage of River bed Protection work at foundation location'
,damageduetoflotingbodies as 'Description of damage due to impact of floating bodies'
,Probleamduetooverloading as 'Description of Problems due to overloading'
,LocationOfCracksConcrete as 'Location Of Cracks Concrete'
,NatureofCracksConcrete as 'Nature of Cracks Concrete'
,WidthofcracksConcrete as 'Width of cracks Concrete(mm)'
,LengthofCracksConcrete as 'Length of Cracks Concrete(mm)'
,PercentageOfVisualSurfaceCracked as 'Percentage Of Visual Surface Cracked'
,NumberofspallsLocationConcrete as 'Number of spalls Location Concrete'
,TotalAreaOfSpallingConcrete as 'Total Area Of Spalling Concrete(sqm)'
,Depthofspallingconcrete as 'Depth of spalling concrete(m)'
,PercentageofCorrosion as 'Percentage Of Corrosion to be measured with respect to bar Diameter'
,ElementInspectedbutnotmeasured as 'Element Inspected but not measured'
,ce.[Description] as 'Abutment Foundation Condition Extent'
,cs.[Description] as 'Abutment Foundation Condition Severity'
,cs1.[Description] as 'Pier Foundation Condition Severity'
,ce1.[Description] as 'Pier Foundation Condition Extent'
,fc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.FoundationCondition fc
INNER JOIN [BMS].[LocationDetails] ld ON fc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=fc.AbutmentFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=fc.AbutmentFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTCondExt ce1 ON ce1.CondExtType=fc.PierFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs1 ON cs1.CondSevType=fc.PierFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=fc.FoundationMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=fc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
End
ELSE IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL)
BEGIN
select BridgeCode as 'Bridge Code'
,SurveyID as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,LengthofCrack as 'Length of cracks (m)'
,Noofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks 'Location of cracks'
,Spalling as 'Spalling'
,NoofBarsExposed as 'No of bars exposed'
,CorrosionofReinforcement as 'Corrosion of Reinforcement (sqm)'
,LocationofCorrosion as'Location of corrosion'
,PoorConcrete 'Poor concrete'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,cgc.Remarks
,S.[Description] as 'Season'
from BMS.CrossGirderCondition cgc
inner join BMS.LocationDetails ld on cgc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON cgc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=cgc.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=cgc.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=cgc.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=cgc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,dsc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,dst.[Description] as 'Deck surface material type'
,st.[Description] as 'Deck surface cracking type'
,CrackingCond as 'Cracking Condition'
,AreaofFineCracking as 'Area of fine cracking'
,AreaofWideCracking as 'Area of wide cracking'
,areaofsurfacecrack as 'Area of surface cracking'
,Potholes
,Ravelling
,totalareaofdepression as 'Total area of depression'
,CorrugationsRipples as 'Corrugation ripples'
,Spalling
,ReinforcementExposed as 'Reinforcement exposed'
,PoorConcrete as 'Poor concrete'
,fp.[Description] as 'Footpath type'
,NatureOfDamage as 'Nature of damage'
,totalnumberofductsblocked as 'Total number of ducts blocked'
,FootpathDamagedPortion as 'footpath damaged portion'
,percentageoffootpathdamaged as 'percentage of footpath damaged'
,pondingofwater as 'ponding of water'
,cs.[Description] as 'Surface Condition Severity'
,ce.[Description] as 'Surface Condition Extent'
,dsc.Remarks
,S.[Description] as Season
from BMS.DeckSurfaceCondition dsc
INNER JOIN [BMS].[LocationDetails] ld ON dsc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=dsc.SurfaceConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=dsc.SurfaceConditionSeverity
LEFT OUTER JOIN BMS.LKPTSurfType st ON st.SurfType= dsc.DeckSurfaceCrackingType
LEFT OUTER JOIN bms.LKPTFPType ft ON ft.FPType=dsc.FootpathType
LEFT OUTER JOIN BMS.LKPTDeckSurfMaterType dst ON dst.DeckSurfMaterType= dsc.DeckSurfaceMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsc.Season
LEFT OUTER JOIN BMS.LKPTFPType fp on dsc.FootpathType = fp.FPType
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,drn.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,NoofspoutsfilledwithdebrisNum as 'No of spouts filled with debris'
,CorrosionofGrills as 'Corrosion of grills'
,NospoutswithoutgrillsNum as 'No of spouts without grills'
,PropercrossslopeinSuperStructure as 'Proper cross slope in super sturcture'
,OrientationofDrainagepipe as 'Orientation of drainage pipe'
,PipeMaterial as 'Pipe material'
,LeachingSpallingNearPipe as 'Leaching or spalling near pipe'
,noofspoutsendedatsoffit as 'No of spouts ended at soffit'
,Noofspoutpipesmissing as 'No of spout pipes missing'
,Pipeprojectionbelowsoffit as 'Pipe projection below soffit'
,collectionpitatdrainage as 'Collection pit at drainage'
,drn.Remarks
,S.[Description] as 'Season'
from BMS.DrainSpoutCondition drn
INNER JOIN [BMS].[LocationDetails] ld ON drn.BridgeCode = ld.BridgeID
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=drn.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,rc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,rt.[Description] as 'Railing type'
,Damagetoouter as 'Damage to outer'
,Looseordamagedfixings as 'Loose or damaged fixings'
,DeteriarationofpaintSqm as 'Deterioration of paint (Sqm)'
,NumberofpipesmissingNum as 'Number of pipes missing'
,Totallengthofmissingpipes as 'Total length of missing pipes'
,NumberofpostsmissingNum as 'Number of posts missing'
,Cracks
,DetailsofDamagedRailing as 'Details of Damaged Railing'
,DamagedCrashBarrier as 'Damaged Crash Barrier'
,Spalling
,LengthRequiredtotalreplacement as 'Length Required total replacement'
,cs.[Description] as 'Railing Condition Severity'
,ce.[Description] as 'Railing Condition Extent'
,rc.Remarks
,S.[Description] as 'Season'
from BMS.RailingCondition rc
INNER JOIN [BMS].[LocationDetails] ld ON rc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=rc.RailingConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=rc.RailingConditionSeverity
LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=rc.RailingType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=rc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,jc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment or Pier No'
,et.[Description] as 'Expansion Joint type'
,Concretedamageatexpansionjoint as 'Concrete damage at expansion joint'
,Damageorcorrosiontometalparts as 'Damage or corrosion to metal parts'
,Damagetorubberwaterseals as 'Damage to rubber water seals'
,LooseorDamagedfixtures as 'Loose or damaged fixtures'
,Signsofleakageunderneaththedeck as 'Signs of leakage underneath the deck'
,DebrisorVegetationinjoint as 'Debris or vegetation in joint'
,CheckforProperVerticalAlignment as 'Check for proper vertical alignment'
,soundatexpjoint as 'Sound at joint'
,cs.[Description]as 'Joint Condition Severity'
,ce.[Description] as 'Joint Condition Extent'
,jc.Remarks
,S.[Description] as 'Season'
from BMS.JointCondition jc
INNER JOIN [BMS].[LocationDetails] ld ON jc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=jc.JointConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=jc.JointConditionSeverity
LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=jc.ExpansionJointType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=jc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,slb.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Types of Crack'
,Lengthofcrack as 'Length of crack (m)'
,Numberofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,NumberofSpalls as 'No of Spalls'
,Spalling
,DepthOfEachSpall as 'Depth of each spall'
,Noofbarsexposed as 'No of bars exposed'
,Corrosionofreinforcement as 'Corrosion or reinforcement'
,PercentageofCorrosion as 'Corrosion (%)'
,PitCorrosion as 'Pit corrosion'
,Locationofcorrosionofreinforcement as 'Location of corrosion of reinforcement'
,PoorConcrete as 'Poor concrete'
,Floreseffectedlocationno as 'Flores Effected Location No'
,DeflectionVisible as 'Deflection visible'
,Excessivevibrationisobserved as 'Excessive vibration observed'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,hitslabbyhammer as 'Sound due to hit slab by hammer'
,pondingofwater as 'Ponding of water'
,locationsofspotswhereconcretediscoloured as 'Locations where concrete discoloured'
,AnchorForCrossPreStressing as 'Anchor for cross prestressing'
,NumberofDamagedAnchorinaSpan as 'No of damaged anchors in a span'
,DescriptionofDamage as 'Damage description'
,DegreeofCorrosionoftheAnchorageend as 'Degree of corrosion of the anchorageend'
,DescriptionofDamageofDucts as 'Description of Damage of Ducts'
,NumberofLooseStrands as 'No of Loose strands'
,TotalNumberofStrandsateachAnchorage as 'Total no of strands at each anchorage'
,ElementinspectedbutnotMeasured as 'Element inspected but not measured'
,VerticalDeflectionofContilevertip as 'Vertical deflection of contilevertip'
,ModerateDeflection as 'Moderate deflection'
,ExcessiveDeflection as 'Excessive deflection'
,ConditionofJointBetweenDeckSlabandGirders as 'Condition of joint between deckslab and girders'
,dripcourseatedgofslab as 'Drip course at edge of slab'
,cs.[Description] as 'Slab Condition Severity'
,ce.[Description] as 'Slab Condition Extent'
,slb.Remarks
,S.[Description] as 'Season'
from BMS.DeckSlabCondition slb
INNER JOIN [BMS].[LocationDetails] ld ON slb.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=slb.SlabconditionExtent
LEFT OUTER JOIN bms.LKPTCrkType ct ON ct.CrackType=slb.Typeofcracks
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=slb.SlabConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=slb.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=slb.ConditionofPainting
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=slb.ConditionofSteelMembers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=slb.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,gc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,Lengthofcrack as 'Length of crack (m)'
,NumberofcracksNum as 'Number of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,Spalling as 'Spalling / Rusting (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,PoorConcrete as 'Poor Concrete / Steel (Sqm)'
,DeflectionVisible as 'Deflection Visible'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel numbers'
,AnchorForCrossPreStressing as 'Anchor For Cross Pre Stressing'
,NoOfanchordamagedinspan as 'Number of Damaged Anchor in a Span'
,DegreeofCorrosionatAnchorage as 'Degree of Corrosion of the Anchorage end'
,DescofDmgofDucts as 'Description for Damage of Ducts'
,NumberofLooseStrands as 'Number of Loose Strands'
,NoOfstrandsatanchorage as 'Number of Strands at each Anchorage'
,Inspectedbutnotmeasured as 'Element inspected but not Measured'
,SpallsinaSpan as 'Spalls in a Span'
,NumberOfSpallLocation as 'Number Of Spall Location'
,numberofBarsExposedandCorroded as 'number of Bars Exposed and Corroded'
,PercentageOfCorrosion as 'Percentage Of Corrosion '
,Floreseffectedlocationno as 'Number of locations in a span effected by efflorescence, dampness and leakage'
,cs.[Description] as 'Girder condition Severity'
,ce.[Description] as 'Girder condition Extent'
,gc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.GirderCondition gc
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON gc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON gc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=gc.GirderConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=gc.GirderConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=gc.conditionofconnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=gc.conditionofpaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=gc.conditionofsteelnumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=gc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,fc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment/Pier Number'
,AM.[Description] as 'Foundation Material Type'
,FoundationScourobserved as 'Foundation Scour observed'
,ScourDepth as 'Scour Depth (m)'
,FoundationSettlementisobserved as 'Foundation Settlement is observed'
,settlementobserved as 'settlement observed (m)'
,Cracking as 'Cracking (m)'
,Spalling as 'Spalling (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,Bulging as 'Bulging (Sqm)'
,PoorPointing as 'Poor Pointing (Sqm)'
,DeteriorationofBricksorStones as 'Deterioration of Bricks or Stones (Sqm)'
,damagedbedprotection as 'Observed Dislodgement and damage of River bed Protection work at foundation location'
,damageduetoflotingbodies as 'Description of damage due to impact of floating bodies'
,Probleamduetooverloading as 'Description of Problems due to overloading'
,LocationOfCracksConcrete as 'Location Of Cracks Concrete'
,NatureofCracksConcrete as 'Nature of Cracks Concrete'
,WidthofcracksConcrete as 'Width of cracks Concrete(mm)'
,LengthofCracksConcrete as 'Length of Cracks Concrete(mm)'
,PercentageOfVisualSurfaceCracked as 'Percentage Of Visual Surface Cracked'
,NumberofspallsLocationConcrete as 'Number of spalls Location Concrete'
,TotalAreaOfSpallingConcrete as 'Total Area Of Spalling Concrete(sqm)'
,Depthofspallingconcrete as 'Depth of spalling concrete(m)'
,PercentageofCorrosion as 'Percentage Of Corrosion to be measured with respect to bar Diameter'
,ElementInspectedbutnotmeasured as 'Element Inspected but not measured'
,ce.[Description] as 'Abutment Foundation Condition Extent'
,cs.[Description] as 'Abutment Foundation Condition Severity'
,cs1.[Description] as 'Pier Foundation Condition Severity'
,ce1.[Description] as 'Pier Foundation Condition Extent'
,fc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.FoundationCondition fc
INNER JOIN [BMS].[LocationDetails] ld ON fc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=fc.AbutmentFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=fc.AbutmentFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTCondExt ce1 ON ce1.CondExtType=fc.PierFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs1 ON cs1.CondSevType=fc.PierFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=fc.FoundationMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=fc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
End
ELSE IF (@userType = 'D' and @hType is NULL)
BEGIN
select BridgeCode as 'Bridge Code'
,SurveyID as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,LengthofCrack as 'Length of cracks (m)'
,Noofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks 'Location of cracks'
,Spalling as 'Spalling'
,NoofBarsExposed as 'No of bars exposed'
,CorrosionofReinforcement as 'Corrosion of Reinforcement (sqm)'
,LocationofCorrosion as'Location of corrosion'
,PoorConcrete 'Poor concrete'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,cgc.Remarks
,S.[Description] as 'Season'
from BMS.CrossGirderCondition cgc
inner join BMS.LocationDetails ld on cgc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON cgc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=cgc.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=cgc.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=cgc.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=cgc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,dsc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,dst.[Description] as 'Deck surface material type'
,st.[Description] as 'Deck surface cracking type'
,CrackingCond as 'Cracking Condition'
,AreaofFineCracking as 'Area of fine cracking'
,AreaofWideCracking as 'Area of wide cracking'
,areaofsurfacecrack as 'Area of surface cracking'
,Potholes
,Ravelling
,totalareaofdepression as 'Total area of depression'
,CorrugationsRipples as 'Corrugation ripples'
,Spalling
,ReinforcementExposed as 'Reinforcement exposed'
,PoorConcrete as 'Poor concrete'
,Fp.[Description] as 'Footpath type'
,NatureOfDamage as 'Nature of damage'
,totalnumberofductsblocked as 'Total number of ducts blocked'
,FootpathDamagedPortion as 'footpath damaged portion'
,percentageoffootpathdamaged as 'percentage of footpath damaged'
,pondingofwater as 'ponding of water'
,cs.[Description] as 'Surface Condition Severity'
,ce.[Description] as 'Surface Condition Extent'
,dsc.Remarks
,S.[Description] as Season
from BMS.DeckSurfaceCondition dsc
INNER JOIN [BMS].[LocationDetails] ld ON dsc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=dsc.SurfaceConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=dsc.SurfaceConditionSeverity
LEFT OUTER JOIN BMS.LKPTSurfType st ON st.SurfType= dsc.DeckSurfaceCrackingType
LEFT OUTER JOIN bms.LKPTFPType ft ON ft.FPType=dsc.FootpathType
LEFT OUTER JOIN BMS.LKPTDeckSurfMaterType dst ON dst.DeckSurfMaterType= dsc.DeckSurfaceMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsc.Season
LEFT OUTER JOIN BMS.LKPTFPType fp on dsc.FootpathType = fp.FPType
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,drn.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,NoofspoutsfilledwithdebrisNum as 'No of spouts filled with debris'
,CorrosionofGrills as 'Corrosion of grills'
,NospoutswithoutgrillsNum as 'No of spouts without grills'
,PropercrossslopeinSuperStructure as 'Proper cross slope in super sturcture'
,OrientationofDrainagepipe as 'Orientation of drainage pipe'
,PipeMaterial as 'Pipe material'
,LeachingSpallingNearPipe as 'Leaching or spalling near pipe'
,noofspoutsendedatsoffit as 'No of spouts ended at soffit'
,Noofspoutpipesmissing as 'No of spout pipes missing'
,Pipeprojectionbelowsoffit as 'Pipe projection below soffit'
,collectionpitatdrainage as 'Collection pit at drainage'
,drn.Remarks
,S.[Description] as 'Season'
from BMS.DrainSpoutCondition drn
INNER JOIN [BMS].[LocationDetails] ld ON drn.BridgeCode = ld.BridgeID
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=drn.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,rc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,rt.[Description] as 'Railing type'
,Damagetoouter as 'Damage to outer'
,Looseordamagedfixings as 'Loose or damaged fixings'
,DeteriarationofpaintSqm as 'Deterioration of paint (Sqm)'
,NumberofpipesmissingNum as 'Number of pipes missing'
,Totallengthofmissingpipes as 'Total length of missing pipes'
,NumberofpostsmissingNum as 'Number of posts missing'
,Cracks
,DetailsofDamagedRailing as 'Details of Damaged Railing'
,DamagedCrashBarrier as 'Damaged Crash Barrier'
,Spalling
,LengthRequiredtotalreplacement as 'Length Required total replacement'
,cs.[Description] as 'Railing Condition Severity'
,ce.[Description] as 'Railing Condition Extent'
,rc.Remarks
,S.[Description] as 'Season'
from BMS.RailingCondition rc
INNER JOIN [BMS].[LocationDetails] ld ON rc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=rc.RailingConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=rc.RailingConditionSeverity
LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=rc.RailingType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=rc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,jc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment or Pier No'
,et.[Description] as 'Expansion Joint type'
,Concretedamageatexpansionjoint as 'Concrete damage at expansion joint'
,Damageorcorrosiontometalparts as 'Damage or corrosion to metal parts'
,Damagetorubberwaterseals as 'Damage to rubber water seals'
,LooseorDamagedfixtures as 'Loose or damaged fixtures'
,Signsofleakageunderneaththedeck as 'Signs of leakage underneath the deck'
,DebrisorVegetationinjoint as 'Debris or vegetation in joint'
,CheckforProperVerticalAlignment as 'Check for proper vertical alignment'
,soundatexpjoint as 'Sound at joint'
,cs.[Description]as 'Joint Condition Severity'
,ce.[Description] as 'Joint Condition Extent'
,jc.Remarks
,S.[Description] as 'Season'
from BMS.JointCondition jc
INNER JOIN [BMS].[LocationDetails] ld ON jc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=jc.JointConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=jc.JointConditionSeverity
LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=jc.ExpansionJointType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=jc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,slb.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Types of Crack'
,Lengthofcrack as 'Length of crack (m)'
,Numberofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,NumberofSpalls as 'No of Spalls'
,Spalling
,DepthOfEachSpall as 'Depth of each spall'
,Noofbarsexposed as 'No of bars exposed'
,Corrosionofreinforcement as 'Corrosion or reinforcement'
,PercentageofCorrosion as 'Corrosion (%)'
,PitCorrosion as 'Pit corrosion'
,Locationofcorrosionofreinforcement as 'Location of corrosion of reinforcement'
,PoorConcrete as 'Poor concrete'
,Floreseffectedlocationno as 'Flores Effected Location No'
,DeflectionVisible as 'Deflection visible'
,Excessivevibrationisobserved as 'Excessive vibration observed'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,hitslabbyhammer as 'Sound due to hit slab by hammer'
,pondingofwater as 'Ponding of water'
,locationsofspotswhereconcretediscoloured as 'Locations where concrete discoloured'
,AnchorForCrossPreStressing as 'Anchor for cross prestressing'
,NumberofDamagedAnchorinaSpan as 'No of damaged anchors in a span'
,DescriptionofDamage as 'Damage description'
,DegreeofCorrosionoftheAnchorageend as 'Degree of corrosion of the anchorageend'
,DescriptionofDamageofDucts as 'Description of Damage of Ducts'
,NumberofLooseStrands as 'No of Loose strands'
,TotalNumberofStrandsateachAnchorage as 'Total no of strands at each anchorage'
,ElementinspectedbutnotMeasured as 'Element inspected but not measured'
,VerticalDeflectionofContilevertip as 'Vertical deflection of contilevertip'
,ModerateDeflection as 'Moderate deflection'
,ExcessiveDeflection as 'Excessive deflection'
,ConditionofJointBetweenDeckSlabandGirders as 'Condition of joint between deckslab and girders'
,dripcourseatedgofslab as 'Drip course at edge of slab'
,cs.[Description] as 'Slab Condition Severity'
,ce.[Description] as 'Slab Condition Extent'
,slb.Remarks
,S.[Description] as 'Season'
from BMS.DeckSlabCondition slb
INNER JOIN [BMS].[LocationDetails] ld ON slb.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=slb.SlabconditionExtent
LEFT OUTER JOIN bms.LKPTCrkType ct ON ct.CrackType=slb.Typeofcracks
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=slb.SlabConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=slb.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=slb.ConditionofPainting
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=slb.ConditionofSteelMembers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=slb.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,gc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,Lengthofcrack as 'Length of crack (m)'
,NumberofcracksNum as 'Number of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,Spalling as 'Spalling / Rusting (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,PoorConcrete as 'Poor Concrete / Steel (Sqm)'
,DeflectionVisible as 'Deflection Visible'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel numbers'
,AnchorForCrossPreStressing as 'Anchor For Cross Pre Stressing'
,NoOfanchordamagedinspan as 'Number of Damaged Anchor in a Span'
,DegreeofCorrosionatAnchorage as 'Degree of Corrosion of the Anchorage end'
,DescofDmgofDucts as 'Description for Damage of Ducts'
,NumberofLooseStrands as 'Number of Loose Strands'
,NoOfstrandsatanchorage as 'Number of Strands at each Anchorage'
,Inspectedbutnotmeasured as 'Element inspected but not Measured'
,SpallsinaSpan as 'Spalls in a Span'
,NumberOfSpallLocation as 'Number Of Spall Location'
,numberofBarsExposedandCorroded as 'number of Bars Exposed and Corroded'
,PercentageOfCorrosion as 'Percentage Of Corrosion '
,Floreseffectedlocationno as 'Number of locations in a span effected by efflorescence, dampness and leakage'
,cs.[Description] as 'Girder condition Severity'
,ce.[Description] as 'Girder condition Extent'
,gc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.GirderCondition gc
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON gc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON gc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=gc.GirderConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=gc.GirderConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=gc.conditionofconnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=gc.conditionofpaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=gc.conditionofsteelnumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=gc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,fc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment/Pier Number'
,AM.[Description] as 'Foundation Material Type'
,FoundationScourobserved as 'Foundation Scour observed'
,ScourDepth as 'Scour Depth (m)'
,FoundationSettlementisobserved as 'Foundation Settlement is observed'
,settlementobserved as 'settlement observed (m)'
,Cracking as 'Cracking (m)'
,Spalling as 'Spalling (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,Bulging as 'Bulging (Sqm)'
,PoorPointing as 'Poor Pointing (Sqm)'
,DeteriorationofBricksorStones as 'Deterioration of Bricks or Stones (Sqm)'
,damagedbedprotection as 'Observed Dislodgement and damage of River bed Protection work at foundation location'
,damageduetoflotingbodies as 'Description of damage due to impact of floating bodies'
,Probleamduetooverloading as 'Description of Problems due to overloading'
,LocationOfCracksConcrete as 'Location Of Cracks Concrete'
,NatureofCracksConcrete as 'Nature of Cracks Concrete'
,WidthofcracksConcrete as 'Width of cracks Concrete(mm)'
,LengthofCracksConcrete as 'Length of Cracks Concrete(mm)'
,PercentageOfVisualSurfaceCracked as 'Percentage Of Visual Surface Cracked'
,NumberofspallsLocationConcrete as 'Number of spalls Location Concrete'
,TotalAreaOfSpallingConcrete as 'Total Area Of Spalling Concrete(sqm)'
,Depthofspallingconcrete as 'Depth of spalling concrete(m)'
,PercentageofCorrosion as 'Percentage Of Corrosion to be measured with respect to bar Diameter'
,ElementInspectedbutnotmeasured as 'Element Inspected but not measured'
,ce.[Description] as 'Abutment Foundation Condition Extent'
,cs.[Description] as 'Abutment Foundation Condition Severity'
,cs1.[Description] as 'Pier Foundation Condition Severity'
,ce1.[Description] as 'Pier Foundation Condition Extent'
,fc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.FoundationCondition fc
INNER JOIN [BMS].[LocationDetails] ld ON fc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=fc.AbutmentFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=fc.AbutmentFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTCondExt ce1 ON ce1.CondExtType=fc.PierFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs1 ON cs1.CondSevType=fc.PierFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=fc.FoundationMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=fc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
END
ELSE
BEGIN
IF @hType = 'C'
BEGIN
select BridgeCode as 'Bridge Code'
,SurveyID as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,LengthofCrack as 'Length of cracks (m)'
,Noofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks 'Location of cracks'
,Spalling as 'Spalling'
,NoofBarsExposed as 'No of bars exposed'
,CorrosionofReinforcement as 'Corrosion of Reinforcement (sqm)'
,LocationofCorrosion as'Location of corrosion'
,PoorConcrete 'Poor concrete'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,cgc.Remarks
,S.[Description] as 'Season'
from BMS.CrossGirderCondition cgc
inner join BMS.LocationDetails ld on cgc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON cgc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=cgc.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=cgc.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=cgc.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=cgc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,dsc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,dst.[Description] as 'Deck surface material type'
,st.[Description] as 'Deck surface cracking type'
,CrackingCond as 'Cracking Condition'
,AreaofFineCracking as 'Area of fine cracking'
,AreaofWideCracking as 'Area of wide cracking'
,areaofsurfacecrack as 'Area of surface cracking'
,Potholes
,Ravelling
,totalareaofdepression as 'Total area of depression'
,CorrugationsRipples as 'Corrugation ripples'
,Spalling
,ReinforcementExposed as 'Reinforcement exposed'
,PoorConcrete as 'Poor concrete'
,Fp.[Description] as 'Footpath type'
,NatureOfDamage as 'Nature of damage'
,totalnumberofductsblocked as 'Total number of ducts blocked'
,FootpathDamagedPortion as 'footpath damaged portion'
,percentageoffootpathdamaged as 'percentage of footpath damaged'
,pondingofwater as 'ponding of water'
,cs.[Description] as 'Surface Condition Severity'
,ce.[Description] as 'Surface Condition Extent'
,dsc.Remarks
,S.[Description] as Season
from BMS.DeckSurfaceCondition dsc
INNER JOIN [BMS].[LocationDetails] ld ON dsc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=dsc.SurfaceConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=dsc.SurfaceConditionSeverity
LEFT OUTER JOIN BMS.LKPTSurfType st ON st.SurfType= dsc.DeckSurfaceCrackingType
LEFT OUTER JOIN bms.LKPTFPType ft ON ft.FPType=dsc.FootpathType
LEFT OUTER JOIN BMS.LKPTDeckSurfMaterType dst ON dst.DeckSurfMaterType= dsc.DeckSurfaceMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsc.Season
LEFT OUTER JOIN BMS.LKPTFPType fp on dsc.FootpathType = fp.FPType
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,drn.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,NoofspoutsfilledwithdebrisNum as 'No of spouts filled with debris'
,CorrosionofGrills as 'Corrosion of grills'
,NospoutswithoutgrillsNum as 'No of spouts without grills'
,PropercrossslopeinSuperStructure as 'Proper cross slope in super sturcture'
,OrientationofDrainagepipe as 'Orientation of drainage pipe'
,PipeMaterial as 'Pipe material'
,LeachingSpallingNearPipe as 'Leaching or spalling near pipe'
,noofspoutsendedatsoffit as 'No of spouts ended at soffit'
,Noofspoutpipesmissing as 'No of spout pipes missing'
,Pipeprojectionbelowsoffit as 'Pipe projection below soffit'
,collectionpitatdrainage as 'Collection pit at drainage'
,drn.Remarks
,S.[Description] as 'Season'
from BMS.DrainSpoutCondition drn
INNER JOIN [BMS].[LocationDetails] ld ON drn.BridgeCode = ld.BridgeID
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=drn.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,rc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,rt.[Description] as 'Railing type'
,Damagetoouter as 'Damage to outer'
,Looseordamagedfixings as 'Loose or damaged fixings'
,DeteriarationofpaintSqm as 'Deterioration of paint (Sqm)'
,NumberofpipesmissingNum as 'Number of pipes missing'
,Totallengthofmissingpipes as 'Total length of missing pipes'
,NumberofpostsmissingNum as 'Number of posts missing'
,Cracks
,DetailsofDamagedRailing as 'Details of Damaged Railing'
,DamagedCrashBarrier as 'Damaged Crash Barrier'
,Spalling
,LengthRequiredtotalreplacement as 'Length Required total replacement'
,cs.[Description] as 'Railing Condition Severity'
,ce.[Description] as 'Railing Condition Extent'
,rc.Remarks
,S.[Description] as 'Season'
from BMS.RailingCondition rc
INNER JOIN [BMS].[LocationDetails] ld ON rc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=rc.RailingConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=rc.RailingConditionSeverity
LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=rc.RailingType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=rc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,jc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment or Pier No'
,et.[Description] as 'Expansion Joint type'
,Concretedamageatexpansionjoint as 'Concrete damage at expansion joint'
,Damageorcorrosiontometalparts as 'Damage or corrosion to metal parts'
,Damagetorubberwaterseals as 'Damage to rubber water seals'
,LooseorDamagedfixtures as 'Loose or damaged fixtures'
,Signsofleakageunderneaththedeck as 'Signs of leakage underneath the deck'
,DebrisorVegetationinjoint as 'Debris or vegetation in joint'
,CheckforProperVerticalAlignment as 'Check for proper vertical alignment'
,soundatexpjoint as 'Sound at joint'
,cs.[Description]as 'Joint Condition Severity'
,ce.[Description] as 'Joint Condition Extent'
,jc.Remarks
,S.[Description] as 'Season'
from BMS.JointCondition jc
INNER JOIN [BMS].[LocationDetails] ld ON jc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=jc.JointConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=jc.JointConditionSeverity
LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=jc.ExpansionJointType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=jc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,slb.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Types of Crack'
,Lengthofcrack as 'Length of crack (m)'
,Numberofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,NumberofSpalls as 'No of Spalls'
,Spalling
,DepthOfEachSpall as 'Depth of each spall'
,Noofbarsexposed as 'No of bars exposed'
,Corrosionofreinforcement as 'Corrosion or reinforcement'
,PercentageofCorrosion as 'Corrosion (%)'
,PitCorrosion as 'Pit corrosion'
,Locationofcorrosionofreinforcement as 'Location of corrosion of reinforcement'
,PoorConcrete as 'Poor concrete'
,Floreseffectedlocationno as 'Flores Effected Location No'
,DeflectionVisible as 'Deflection visible'
,Excessivevibrationisobserved as 'Excessive vibration observed'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,hitslabbyhammer as 'Sound due to hit slab by hammer'
,pondingofwater as 'Ponding of water'
,locationsofspotswhereconcretediscoloured as 'Locations where concrete discoloured'
,AnchorForCrossPreStressing as 'Anchor for cross prestressing'
,NumberofDamagedAnchorinaSpan as 'No of damaged anchors in a span'
,DescriptionofDamage as 'Damage description'
,DegreeofCorrosionoftheAnchorageend as 'Degree of corrosion of the anchorageend'
,DescriptionofDamageofDucts as 'Description of Damage of Ducts'
,NumberofLooseStrands as 'No of Loose strands'
,TotalNumberofStrandsateachAnchorage as 'Total no of strands at each anchorage'
,ElementinspectedbutnotMeasured as 'Element inspected but not measured'
,VerticalDeflectionofContilevertip as 'Vertical deflection of contilevertip'
,ModerateDeflection as 'Moderate deflection'
,ExcessiveDeflection as 'Excessive deflection'
,ConditionofJointBetweenDeckSlabandGirders as 'Condition of joint between deckslab and girders'
,dripcourseatedgofslab as 'Drip course at edge of slab'
,cs.[Description] as 'Slab Condition Severity'
,ce.[Description] as 'Slab Condition Extent'
,slb.Remarks
,S.[Description] as 'Season'
from BMS.DeckSlabCondition slb
INNER JOIN [BMS].[LocationDetails] ld ON slb.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=slb.SlabconditionExtent
LEFT OUTER JOIN bms.LKPTCrkType ct ON ct.CrackType=slb.Typeofcracks
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=slb.SlabConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=slb.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=slb.ConditionofPainting
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=slb.ConditionofSteelMembers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=slb.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,gc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,Lengthofcrack as 'Length of crack (m)'
,NumberofcracksNum as 'Number of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,Spalling as 'Spalling / Rusting (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,PoorConcrete as 'Poor Concrete / Steel (Sqm)'
,DeflectionVisible as 'Deflection Visible'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel numbers'
,AnchorForCrossPreStressing as 'Anchor For Cross Pre Stressing'
,NoOfanchordamagedinspan as 'Number of Damaged Anchor in a Span'
,DegreeofCorrosionatAnchorage as 'Degree of Corrosion of the Anchorage end'
,DescofDmgofDucts as 'Description for Damage of Ducts'
,NumberofLooseStrands as 'Number of Loose Strands'
,NoOfstrandsatanchorage as 'Number of Strands at each Anchorage'
,Inspectedbutnotmeasured as 'Element inspected but not Measured'
,SpallsinaSpan as 'Spalls in a Span'
,NumberOfSpallLocation as 'Number Of Spall Location'
,numberofBarsExposedandCorroded as 'number of Bars Exposed and Corroded'
,PercentageOfCorrosion as 'Percentage Of Corrosion ' ,Floreseffectedlocationno as 'Number of locations in a span effected by efflorescence, dampness and leakage'
,cs.[Description] as 'Girder condition Severity'
,ce.[Description] as 'Girder condition Extent'
,gc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.GirderCondition gc
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON gc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON gc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=gc.GirderConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=gc.GirderConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=gc.conditionofconnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=gc.conditionofpaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=gc.conditionofsteelnumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=gc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,fc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment/Pier Number'
,AM.[Description] as 'Foundation Material Type'
,FoundationScourobserved as 'Foundation Scour observed'
,ScourDepth as 'Scour Depth (m)'
,FoundationSettlementisobserved as 'Foundation Settlement is observed'
,settlementobserved as 'settlement observed (m)'
,Cracking as 'Cracking (m)'
,Spalling as 'Spalling (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,Bulging as 'Bulging (Sqm)'
,PoorPointing as 'Poor Pointing (Sqm)'
,DeteriorationofBricksorStones as 'Deterioration of Bricks or Stones (Sqm)'
,damagedbedprotection as 'Observed Dislodgement and damage of River bed Protection work at foundation location'
,damageduetoflotingbodies as 'Description of damage due to impact of floating bodies'
,Probleamduetooverloading as 'Description of Problems due to overloading'
,LocationOfCracksConcrete as 'Location Of Cracks Concrete'
,NatureofCracksConcrete as 'Nature of Cracks Concrete'
,WidthofcracksConcrete as 'Width of cracks Concrete(mm)'
,LengthofCracksConcrete as 'Length of Cracks Concrete(mm)'
,PercentageOfVisualSurfaceCracked as 'Percentage Of Visual Surface Cracked'
,NumberofspallsLocationConcrete as 'Number of spalls Location Concrete'
,TotalAreaOfSpallingConcrete as 'Total Area Of Spalling Concrete(sqm)'
,Depthofspallingconcrete as 'Depth of spalling concrete(m)'
,PercentageofCorrosion as 'Percentage Of Corrosion to be measured with respect to bar Diameter'
,ElementInspectedbutnotmeasured as 'Element Inspected but not measured'
,ce.[Description] as 'Abutment Foundation Condition Extent'
,cs.[Description] as 'Abutment Foundation Condition Severity'
,cs1.[Description] as 'Pier Foundation Condition Severity'
,ce1.[Description] as 'Pier Foundation Condition Extent'
,fc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.FoundationCondition fc
INNER JOIN [BMS].[LocationDetails] ld ON fc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=fc.AbutmentFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=fc.AbutmentFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTCondExt ce1 ON ce1.CondExtType=fc.PierFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs1 ON cs1.CondSevType=fc.PierFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=fc.FoundationMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=fc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
END
ELSE IF @hType = 'D'
BEGIN
select BridgeCode as 'Bridge Code'
,SurveyID as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,LengthofCrack as 'Length of cracks (m)'
,Noofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks 'Location of cracks'
,Spalling as 'Spalling'
,NoofBarsExposed as 'No of bars exposed'
,CorrosionofReinforcement as 'Corrosion of Reinforcement (sqm)'
,LocationofCorrosion as'Location of corrosion'
,PoorConcrete 'Poor concrete'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,cgc.Remarks
,S.[Description] as 'Season'
from BMS.CrossGirderCondition cgc
inner join BMS.LocationDetails ld on cgc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON cgc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=cgc.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=cgc.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=cgc.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=cgc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,dsc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,dst.[Description] as 'Deck surface material type'
,st.[Description] as 'Deck surface cracking type'
,CrackingCond as 'Cracking Condition'
,AreaofFineCracking as 'Area of fine cracking'
,AreaofWideCracking as 'Area of wide cracking'
,areaofsurfacecrack as 'Area of surface cracking'
,Potholes
,Ravelling
,totalareaofdepression as 'Total area of depression'
,CorrugationsRipples as 'Corrugation ripples'
,Spalling
,ReinforcementExposed as 'Reinforcement exposed'
,PoorConcrete as 'Poor concrete'
,Fp.[Description] as 'Footpath type'
,NatureOfDamage as 'Nature of damage'
,totalnumberofductsblocked as 'Total number of ducts blocked'
,FootpathDamagedPortion as 'footpath damaged portion'
,percentageoffootpathdamaged as 'percentage of footpath damaged'
,pondingofwater as 'ponding of water'
,cs.[Description] as 'Surface Condition Severity'
,ce.[Description] as 'Surface Condition Extent'
,dsc.Remarks
,S.[Description] as Season
from BMS.DeckSurfaceCondition dsc
INNER JOIN [BMS].[LocationDetails] ld ON dsc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=dsc.SurfaceConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=dsc.SurfaceConditionSeverity
LEFT OUTER JOIN BMS.LKPTSurfType st ON st.SurfType= dsc.DeckSurfaceCrackingType
LEFT OUTER JOIN bms.LKPTFPType ft ON ft.FPType=dsc.FootpathType
LEFT OUTER JOIN BMS.LKPTDeckSurfMaterType dst ON dst.DeckSurfMaterType= dsc.DeckSurfaceMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsc.Season
LEFT OUTER JOIN BMS.LKPTFPType fp on dsc.FootpathType = fp.FPType
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,drn.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,NoofspoutsfilledwithdebrisNum as 'No of spouts filled with debris'
,CorrosionofGrills as 'Corrosion of grills'
,NospoutswithoutgrillsNum as 'No of spouts without grills'
,PropercrossslopeinSuperStructure as 'Proper cross slope in super sturcture'
,OrientationofDrainagepipe as 'Orientation of drainage pipe'
,PipeMaterial as 'Pipe material'
,LeachingSpallingNearPipe as 'Leaching or spalling near pipe'
,noofspoutsendedatsoffit as 'No of spouts ended at soffit'
,Noofspoutpipesmissing as 'No of spout pipes missing'
,Pipeprojectionbelowsoffit as 'Pipe projection below soffit'
,collectionpitatdrainage as 'Collection pit at drainage'
,drn.Remarks
,S.[Description] as 'Season'
from BMS.DrainSpoutCondition drn
INNER JOIN [BMS].[LocationDetails] ld ON drn.BridgeCode = ld.BridgeID
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=drn.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,rc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,rt.[Description] as 'Railing type'
,Damagetoouter as 'Damage to outer'
,Looseordamagedfixings as 'Loose or damaged fixings'
,DeteriarationofpaintSqm as 'Deterioration of paint (Sqm)'
,NumberofpipesmissingNum as 'Number of pipes missing'
,Totallengthofmissingpipes as 'Total length of missing pipes'
,NumberofpostsmissingNum as 'Number of posts missing'
,Cracks
,DetailsofDamagedRailing as 'Details of Damaged Railing'
,DamagedCrashBarrier as 'Damaged Crash Barrier'
,Spalling
,LengthRequiredtotalreplacement as 'Length Required total replacement'
,cs.[Description] as 'Railing Condition Severity'
,ce.[Description] as 'Railing Condition Extent'
,rc.Remarks
,S.[Description] as 'Season'
from BMS.RailingCondition rc
INNER JOIN [BMS].[LocationDetails] ld ON rc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=rc.RailingConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=rc.RailingConditionSeverity
LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=rc.RailingType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=rc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,jc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment or Pier No'
,et.[Description] as 'Expansion Joint type'
,Concretedamageatexpansionjoint as 'Concrete damage at expansion joint'
,Damageorcorrosiontometalparts as 'Damage or corrosion to metal parts'
,Damagetorubberwaterseals as 'Damage to rubber water seals'
,LooseorDamagedfixtures as 'Loose or damaged fixtures'
,Signsofleakageunderneaththedeck as 'Signs of leakage underneath the deck'
,DebrisorVegetationinjoint as 'Debris or vegetation in joint'
,CheckforProperVerticalAlignment as 'Check for proper vertical alignment'
,soundatexpjoint as 'Sound at joint'
,cs.[Description]as 'Joint Condition Severity'
,ce.[Description] as 'Joint Condition Extent'
,jc.Remarks
,S.[Description] as 'Season'
from BMS.JointCondition jc
INNER JOIN [BMS].[LocationDetails] ld ON jc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=jc.JointConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=jc.JointConditionSeverity
LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=jc.ExpansionJointType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=jc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,slb.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Types of Crack'
,Lengthofcrack as 'Length of crack (m)'
,Numberofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,NumberofSpalls as 'No of Spalls'
,Spalling
,DepthOfEachSpall as 'Depth of each spall'
,Noofbarsexposed as 'No of bars exposed'
,Corrosionofreinforcement as 'Corrosion or reinforcement'
,PercentageofCorrosion as 'Corrosion (%)'
,PitCorrosion as 'Pit corrosion'
,Locationofcorrosionofreinforcement as 'Location of corrosion of reinforcement'
,PoorConcrete as 'Poor concrete'
,Floreseffectedlocationno as 'Flores Effected Location No'
,DeflectionVisible as 'Deflection visible'
,Excessivevibrationisobserved as 'Excessive vibration observed'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,hitslabbyhammer as 'Sound due to hit slab by hammer'
,pondingofwater as 'Ponding of water'
,locationsofspotswhereconcretediscoloured as 'Locations where concrete discoloured'
,AnchorForCrossPreStressing as 'Anchor for cross prestressing'
,NumberofDamagedAnchorinaSpan as 'No of damaged anchors in a span'
,DescriptionofDamage as 'Damage description'
,DegreeofCorrosionoftheAnchorageend as 'Degree of corrosion of the anchorageend'
,DescriptionofDamageofDucts as 'Description of Damage of Ducts'
,NumberofLooseStrands as 'No of Loose strands'
,TotalNumberofStrandsateachAnchorage as 'Total no of strands at each anchorage'
,ElementinspectedbutnotMeasured as 'Element inspected but not measured'
,VerticalDeflectionofContilevertip as 'Vertical deflection of contilevertip'
,ModerateDeflection as 'Moderate deflection'
,ExcessiveDeflection as 'Excessive deflection'
,ConditionofJointBetweenDeckSlabandGirders as 'Condition of joint between deckslab and girders'
,dripcourseatedgofslab as 'Drip course at edge of slab'
,cs.[Description] as 'Slab Condition Severity'
,ce.[Description] as 'Slab Condition Extent'
,slb.Remarks
,S.[Description] as 'Season'
from BMS.DeckSlabCondition slb
INNER JOIN [BMS].[LocationDetails] ld ON slb.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=slb.SlabconditionExtent
LEFT OUTER JOIN bms.LKPTCrkType ct ON ct.CrackType=slb.Typeofcracks
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=slb.SlabConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=slb.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=slb.ConditionofPainting
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=slb.ConditionofSteelMembers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=slb.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,gc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,Lengthofcrack as 'Length of crack (m)'
,NumberofcracksNum as 'Number of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,Spalling as 'Spalling / Rusting (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,PoorConcrete as 'Poor Concrete / Steel (Sqm)'
,DeflectionVisible as 'Deflection Visible'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel numbers'
,AnchorForCrossPreStressing as 'Anchor For Cross Pre Stressing'
,NoOfanchordamagedinspan as 'Number of Damaged Anchor in a Span'
,DegreeofCorrosionatAnchorage as 'Degree of Corrosion of the Anchorage end'
,DescofDmgofDucts as 'Description for Damage of Ducts'
,NumberofLooseStrands as 'Number of Loose Strands'
,NoOfstrandsatanchorage as 'Number of Strands at each Anchorage'
,Inspectedbutnotmeasured as 'Element inspected but not Measured'
,SpallsinaSpan as 'Spalls in a Span'
,NumberOfSpallLocation as 'Number Of Spall Location'
,numberofBarsExposedandCorroded as 'number of Bars Exposed and Corroded'
,PercentageOfCorrosion as 'Percentage Of Corrosion '
,Floreseffectedlocationno as 'Number of locations in a span effected by efflorescence, dampness and leakage'
,cs.[Description] as 'Girder condition Severity'
,ce.[Description] as 'Girder condition Extent'
,gc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.GirderCondition gc
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON gc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON gc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=gc.GirderConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=gc.GirderConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=gc.conditionofconnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=gc.conditionofpaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=gc.conditionofsteelnumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=gc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,fc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment/Pier Number'
,AM.[Description] as 'Foundation Material Type'
,FoundationScourobserved as 'Foundation Scour observed'
,ScourDepth as 'Scour Depth (m)'
,FoundationSettlementisobserved as 'Foundation Settlement is observed'
,settlementobserved as 'settlement observed (m)'
,Cracking as 'Cracking (m)'
,Spalling as 'Spalling (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,Bulging as 'Bulging (Sqm)'
,PoorPointing as 'Poor Pointing (Sqm)'
,DeteriorationofBricksorStones as 'Deterioration of Bricks or Stones (Sqm)'
,damagedbedprotection as 'Observed Dislodgement and damage of River bed Protection work at foundation location'
,damageduetoflotingbodies as 'Description of damage due to impact of floating bodies'
,Probleamduetooverloading as 'Description of Problems due to overloading'
,LocationOfCracksConcrete as 'Location Of Cracks Concrete'
,NatureofCracksConcrete as 'Nature of Cracks Concrete'
,WidthofcracksConcrete as 'Width of cracks Concrete(mm)'
,LengthofCracksConcrete as 'Length of Cracks Concrete(mm)'
,PercentageOfVisualSurfaceCracked as 'Percentage Of Visual Surface Cracked'
,NumberofspallsLocationConcrete as 'Number of spalls Location Concrete'
,TotalAreaOfSpallingConcrete as 'Total Area Of Spalling Concrete(sqm)'
,Depthofspallingconcrete as 'Depth of spalling concrete(m)'
,PercentageofCorrosion as 'Percentage Of Corrosion to be measured with respect to bar Diameter'
,ElementInspectedbutnotmeasured as 'Element Inspected but not measured'
,ce.[Description] as 'Abutment Foundation Condition Extent'
,cs.[Description] as 'Abutment Foundation Condition Severity'
,cs1.[Description] as 'Pier Foundation Condition Severity'
,ce1.[Description] as 'Pier Foundation Condition Extent'
,fc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.FoundationCondition fc
INNER JOIN [BMS].[LocationDetails] ld ON fc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=fc.AbutmentFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=fc.AbutmentFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTCondExt ce1 ON ce1.CondExtType=fc.PierFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs1 ON cs1.CondSevType=fc.PierFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=fc.FoundationMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=fc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
END
ELSE IF @hType = 'W'
BEGIN
select BridgeCode as 'Bridge Code'
,SurveyID as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,LengthofCrack as 'Length of cracks (m)'
,Noofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks 'Location of cracks'
,Spalling as 'Spalling'
,NoofBarsExposed as 'No of bars exposed'
,CorrosionofReinforcement as 'Corrosion of Reinforcement (sqm)'
,LocationofCorrosion as'Location of corrosion'
,PoorConcrete 'Poor concrete'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,cgc.Remarks
,S.[Description] as 'Season'
from BMS.CrossGirderCondition cgc
inner join BMS.LocationDetails ld on cgc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON cgc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=cgc.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=cgc.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=cgc.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=cgc.Season
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,dsc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,dst.[Description] as 'Deck surface material type'
,st.[Description] as 'Deck surface cracking type'
,CrackingCond as 'Cracking Condition'
,AreaofFineCracking as 'Area of fine cracking'
,AreaofWideCracking as 'Area of wide cracking'
,areaofsurfacecrack as 'Area of surface cracking'
,Potholes
,Ravelling
,totalareaofdepression as 'Total area of depression'
,CorrugationsRipples as 'Corrugation ripples'
,Spalling
,ReinforcementExposed as 'Reinforcement exposed'
,PoorConcrete as 'Poor concrete'
,Fp.[Description] as 'Footpath type'
,NatureOfDamage as 'Nature of damage'
,totalnumberofductsblocked as 'Total number of ducts blocked'
,FootpathDamagedPortion as 'footpath damaged portion'
,percentageoffootpathdamaged as 'percentage of footpath damaged'
,pondingofwater as 'ponding of water'
,cs.[Description] as 'Surface Condition Severity'
,ce.[Description] as 'Surface Condition Extent'
,dsc.Remarks
,S.[Description] as Season
from BMS.DeckSurfaceCondition dsc
INNER JOIN [BMS].[LocationDetails] ld ON dsc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=dsc.SurfaceConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=dsc.SurfaceConditionSeverity
LEFT OUTER JOIN BMS.LKPTSurfType st ON st.SurfType= dsc.DeckSurfaceCrackingType
LEFT OUTER JOIN bms.LKPTFPType ft ON ft.FPType=dsc.FootpathType
LEFT OUTER JOIN BMS.LKPTDeckSurfMaterType dst ON dst.DeckSurfMaterType= dsc.DeckSurfaceMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsc.Season
LEFT OUTER JOIN BMS.LKPTFPType fp on dsc.FootpathType = fp.FPType
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,drn.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,NoofspoutsfilledwithdebrisNum as 'No of spouts filled with debris'
,CorrosionofGrills as 'Corrosion of grills'
,NospoutswithoutgrillsNum as 'No of spouts without grills'
,PropercrossslopeinSuperStructure as 'Proper cross slope in super sturcture'
,OrientationofDrainagepipe as 'Orientation of drainage pipe'
,PipeMaterial as 'Pipe material'
,LeachingSpallingNearPipe as 'Leaching or spalling near pipe'
,noofspoutsendedatsoffit as 'No of spouts ended at soffit'
,Noofspoutpipesmissing as 'No of spout pipes missing'
,Pipeprojectionbelowsoffit as 'Pipe projection below soffit'
,collectionpitatdrainage as 'Collection pit at drainage'
,drn.Remarks
,S.[Description] as 'Season'
from BMS.DrainSpoutCondition drn
INNER JOIN [BMS].[LocationDetails] ld ON drn.BridgeCode = ld.BridgeID
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=drn.Season
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,rc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,rt.[Description] as 'Railing type'
,Damagetoouter as 'Damage to outer'
,Looseordamagedfixings as 'Loose or damaged fixings'
,DeteriarationofpaintSqm as 'Deterioration of paint (Sqm)'
,NumberofpipesmissingNum as 'Number of pipes missing'
,Totallengthofmissingpipes as 'Total length of missing pipes'
,NumberofpostsmissingNum as 'Number of posts missing'
,Cracks
,DetailsofDamagedRailing as 'Details of Damaged Railing'
,DamagedCrashBarrier as 'Damaged Crash Barrier'
,Spalling
,LengthRequiredtotalreplacement as 'Length Required total replacement'
,cs.[Description] as 'Railing Condition Severity'
,ce.[Description] as 'Railing Condition Extent'
,rc.Remarks
,S.[Description] as 'Season'
from BMS.RailingCondition rc
INNER JOIN [BMS].[LocationDetails] ld ON rc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=rc.RailingConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=rc.RailingConditionSeverity
LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=rc.RailingType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=rc.Season
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,jc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment or Pier No'
,et.[Description] as 'Expansion Joint type'
,Concretedamageatexpansionjoint as 'Concrete damage at expansion joint'
,Damageorcorrosiontometalparts as 'Damage or corrosion to metal parts'
,Damagetorubberwaterseals as 'Damage to rubber water seals'
,LooseorDamagedfixtures as 'Loose or damaged fixtures'
,Signsofleakageunderneaththedeck as 'Signs of leakage underneath the deck'
,DebrisorVegetationinjoint as 'Debris or vegetation in joint'
,CheckforProperVerticalAlignment as 'Check for proper vertical alignment'
,soundatexpjoint as 'Sound at joint'
,cs.[Description]as 'Joint Condition Severity'
,ce.[Description] as 'Joint Condition Extent'
,jc.Remarks
,S.[Description] as 'Season'
from BMS.JointCondition jc
INNER JOIN [BMS].[LocationDetails] ld ON jc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=jc.JointConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=jc.JointConditionSeverity
LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=jc.ExpansionJointType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=jc.Season
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,slb.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Types of Crack'
,Lengthofcrack as 'Length of crack (m)'
,Numberofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,NumberofSpalls as 'No of Spalls'
,Spalling
,DepthOfEachSpall as 'Depth of each spall'
,Noofbarsexposed as 'No of bars exposed'
,Corrosionofreinforcement as 'Corrosion or reinforcement'
,PercentageofCorrosion as 'Corrosion (%)'
,PitCorrosion as 'Pit corrosion'
,Locationofcorrosionofreinforcement as 'Location of corrosion of reinforcement'
,PoorConcrete as 'Poor concrete'
,Floreseffectedlocationno as 'Flores Effected Location No'
,DeflectionVisible as 'Deflection visible'
,Excessivevibrationisobserved as 'Excessive vibration observed'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,hitslabbyhammer as 'Sound due to hit slab by hammer'
,pondingofwater as 'Ponding of water'
,locationsofspotswhereconcretediscoloured as 'Locations where concrete discoloured'
,AnchorForCrossPreStressing as 'Anchor for cross prestressing'
,NumberofDamagedAnchorinaSpan as 'No of damaged anchors in a span'
,DescriptionofDamage as 'Damage description'
,DegreeofCorrosionoftheAnchorageend as 'Degree of corrosion of the anchorageend'
,DescriptionofDamageofDucts as 'Description of Damage of Ducts'
,NumberofLooseStrands as 'No of Loose strands'
,TotalNumberofStrandsateachAnchorage as 'Total no of strands at each anchorage'
,ElementinspectedbutnotMeasured as 'Element inspected but not measured'
,VerticalDeflectionofContilevertip as 'Vertical deflection of contilevertip'
,ModerateDeflection as 'Moderate deflection'
,ExcessiveDeflection as 'Excessive deflection'
,ConditionofJointBetweenDeckSlabandGirders as 'Condition of joint between deckslab and girders'
,dripcourseatedgofslab as 'Drip course at edge of slab'
,cs.[Description] as 'Slab Condition Severity'
,ce.[Description] as 'Slab Condition Extent'
,slb.Remarks
,S.[Description] as 'Season'
from BMS.DeckSlabCondition slb
INNER JOIN [BMS].[LocationDetails] ld ON slb.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=slb.SlabconditionExtent
LEFT OUTER JOIN bms.LKPTCrkType ct ON ct.CrackType=slb.Typeofcracks
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=slb.SlabConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=slb.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=slb.ConditionofPainting
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=slb.ConditionofSteelMembers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=slb.Season
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,gc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,Lengthofcrack as 'Length of crack (m)'
,NumberofcracksNum as 'Number of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,Spalling as 'Spalling / Rusting (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,PoorConcrete as 'Poor Concrete / Steel (Sqm)'
,DeflectionVisible as 'Deflection Visible'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel numbers'
,AnchorForCrossPreStressing as 'Anchor For Cross Pre Stressing'
,NoOfanchordamagedinspan as 'Number of Damaged Anchor in a Span'
,DegreeofCorrosionatAnchorage as 'Degree of Corrosion of the Anchorage end'
,DescofDmgofDucts as 'Description for Damage of Ducts'
,NumberofLooseStrands as 'Number of Loose Strands'
,NoOfstrandsatanchorage as 'Number of Strands at each Anchorage'
,Inspectedbutnotmeasured as 'Element inspected but not Measured'
,SpallsinaSpan as 'Spalls in a Span'
,NumberOfSpallLocation as 'Number Of Spall Location'
,numberofBarsExposedandCorroded as 'number of Bars Exposed and Corroded'
,PercentageOfCorrosion as 'Percentage Of Corrosion '
,Floreseffectedlocationno as 'Number of locations in a span effected by efflorescence, dampness and leakage'
,cs.[Description] as 'Girder condition Severity'
,ce.[Description] as 'Girder condition Extent'
,gc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.GirderCondition gc
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON gc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON gc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=gc.GirderConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=gc.GirderConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=gc.conditionofconnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=gc.conditionofpaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=gc.conditionofsteelnumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=gc.Season
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,fc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment/Pier Number'
,AM.[Description] as 'Foundation Material Type'
,FoundationScourobserved as 'Foundation Scour observed'
,ScourDepth as 'Scour Depth (m)'
,FoundationSettlementisobserved as 'Foundation Settlement is observed'
,settlementobserved as 'settlement observed (m)'
,Cracking as 'Cracking (m)'
,Spalling as 'Spalling (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,Bulging as 'Bulging (Sqm)'
,PoorPointing as 'Poor Pointing (Sqm)'
,DeteriorationofBricksorStones as 'Deterioration of Bricks or Stones (Sqm)'
,damagedbedprotection as 'Observed Dislodgement and damage of River bed Protection work at foundation location'
,damageduetoflotingbodies as 'Description of damage due to impact of floating bodies'
,Probleamduetooverloading as 'Description of Problems due to overloading'
,LocationOfCracksConcrete as 'Location Of Cracks Concrete'
,NatureofCracksConcrete as 'Nature of Cracks Concrete'
,WidthofcracksConcrete as 'Width of cracks Concrete(mm)'
,LengthofCracksConcrete as 'Length of Cracks Concrete(mm)'
,PercentageOfVisualSurfaceCracked as 'Percentage Of Visual Surface Cracked'
,NumberofspallsLocationConcrete as 'Number of spalls Location Concrete'
,TotalAreaOfSpallingConcrete as 'Total Area Of Spalling Concrete(sqm)'
,Depthofspallingconcrete as 'Depth of spalling concrete(m)'
,PercentageofCorrosion as 'Percentage Of Corrosion to be measured with respect to bar Diameter'
,ElementInspectedbutnotmeasured as 'Element Inspected but not measured'
,ce.[Description] as 'Abutment Foundation Condition Extent'
,cs.[Description] as 'Abutment Foundation Condition Severity'
,cs1.[Description] as 'Pier Foundation Condition Severity'
,ce1.[Description] as 'Pier Foundation Condition Extent'
,fc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.FoundationCondition fc
INNER JOIN [BMS].[LocationDetails] ld ON fc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=fc.AbutmentFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=fc.AbutmentFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTCondExt ce1 ON ce1.CondExtType=fc.PierFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs1 ON cs1.CondSevType=fc.PierFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=fc.FoundationMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=fc.Season
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
END
ELSE IF @hType = 'MLA'
BEGIN
select BridgeCode as 'Bridge Code'
,SurveyID as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,LengthofCrack as 'Length of cracks (m)'
,Noofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks 'Location of cracks'
,Spalling as 'Spalling'
,NoofBarsExposed as 'No of bars exposed'
,CorrosionofReinforcement as 'Corrosion of Reinforcement (sqm)'
,LocationofCorrosion as'Location of corrosion'
,PoorConcrete 'Poor concrete'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,cgc.Remarks
,S.[Description] as 'Season'
from BMS.CrossGirderCondition cgc
inner join BMS.LocationDetails ld on cgc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON cgc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=cgc.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=cgc.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=cgc.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=cgc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,dsc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,dst.[Description] as 'Deck surface material type'
,st.[Description] as 'Deck surface cracking type'
,CrackingCond as 'Cracking Condition'
,AreaofFineCracking as 'Area of fine cracking'
,AreaofWideCracking as 'Area of wide cracking'
,areaofsurfacecrack as 'Area of surface cracking'
,Potholes
,Ravelling
,totalareaofdepression as 'Total area of depression'
,CorrugationsRipples as 'Corrugation ripples'
,Spalling
,ReinforcementExposed as 'Reinforcement exposed'
,PoorConcrete as 'Poor concrete'
,Fp.[Description] as 'Footpath type'
,NatureOfDamage as 'Nature of damage'
,totalnumberofductsblocked as 'Total number of ducts blocked'
,FootpathDamagedPortion as 'footpath damaged portion'
,percentageoffootpathdamaged as 'percentage of footpath damaged'
,pondingofwater as 'ponding of water'
,cs.[Description] as 'Surface Condition Severity'
,ce.[Description] as 'Surface Condition Extent'
,dsc.Remarks
,S.[Description] as Season
from BMS.DeckSurfaceCondition dsc
INNER JOIN [BMS].[LocationDetails] ld ON dsc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=dsc.SurfaceConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=dsc.SurfaceConditionSeverity
LEFT OUTER JOIN BMS.LKPTSurfType st ON st.SurfType= dsc.DeckSurfaceCrackingType
LEFT OUTER JOIN bms.LKPTFPType ft ON ft.FPType=dsc.FootpathType
LEFT OUTER JOIN BMS.LKPTDeckSurfMaterType dst ON dst.DeckSurfMaterType= dsc.DeckSurfaceMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsc.Season
LEFT OUTER JOIN BMS.LKPTFPType fp on dsc.FootpathType = fp.FPType
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,drn.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,NoofspoutsfilledwithdebrisNum as 'No of spouts filled with debris'
,CorrosionofGrills as 'Corrosion of grills'
,NospoutswithoutgrillsNum as 'No of spouts without grills'
,PropercrossslopeinSuperStructure as 'Proper cross slope in super sturcture'
,OrientationofDrainagepipe as 'Orientation of drainage pipe'
,PipeMaterial as 'Pipe material'
,LeachingSpallingNearPipe as 'Leaching or spalling near pipe'
,noofspoutsendedatsoffit as 'No of spouts ended at soffit'
,Noofspoutpipesmissing as 'No of spout pipes missing'
,Pipeprojectionbelowsoffit as 'Pipe projection below soffit'
,collectionpitatdrainage as 'Collection pit at drainage'
,drn.Remarks
,S.[Description] as 'Season'
from BMS.DrainSpoutCondition drn
INNER JOIN [BMS].[LocationDetails] ld ON drn.BridgeCode = ld.BridgeID
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=drn.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,rc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,rt.[Description] as 'Railing type'
,Damagetoouter as 'Damage to outer'
,Looseordamagedfixings as 'Loose or damaged fixings'
,DeteriarationofpaintSqm as 'Deterioration of paint (Sqm)'
,NumberofpipesmissingNum as 'Number of pipes missing'
,Totallengthofmissingpipes as 'Total length of missing pipes'
,NumberofpostsmissingNum as 'Number of posts missing'
,Cracks
,DetailsofDamagedRailing as 'Details of Damaged Railing'
,DamagedCrashBarrier as 'Damaged Crash Barrier'
,Spalling
,LengthRequiredtotalreplacement as 'Length Required total replacement'
,cs.[Description] as 'Railing Condition Severity'
,ce.[Description] as 'Railing Condition Extent'
,rc.Remarks
,S.[Description] as 'Season'
from BMS.RailingCondition rc
INNER JOIN [BMS].[LocationDetails] ld ON rc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=rc.RailingConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=rc.RailingConditionSeverity
LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=rc.RailingType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=rc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,jc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment or Pier No'
,et.[Description] as 'Expansion Joint type'
,Concretedamageatexpansionjoint as 'Concrete damage at expansion joint'
,Damageorcorrosiontometalparts as 'Damage or corrosion to metal parts'
,Damagetorubberwaterseals as 'Damage to rubber water seals'
,LooseorDamagedfixtures as 'Loose or damaged fixtures'
,Signsofleakageunderneaththedeck as 'Signs of leakage underneath the deck'
,DebrisorVegetationinjoint as 'Debris or vegetation in joint'
,CheckforProperVerticalAlignment as 'Check for proper vertical alignment'
,soundatexpjoint as 'Sound at joint'
,cs.[Description]as 'Joint Condition Severity'
,ce.[Description] as 'Joint Condition Extent'
,jc.Remarks
,S.[Description] as 'Season'
from BMS.JointCondition jc
INNER JOIN [BMS].[LocationDetails] ld ON jc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=jc.JointConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=jc.JointConditionSeverity
LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=jc.ExpansionJointType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=jc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,slb.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Types of Crack'
,Lengthofcrack as 'Length of crack (m)'
,Numberofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,NumberofSpalls as 'No of Spalls'
,Spalling
,DepthOfEachSpall as 'Depth of each spall'
,Noofbarsexposed as 'No of bars exposed'
,Corrosionofreinforcement as 'Corrosion or reinforcement'
,PercentageofCorrosion as 'Corrosion (%)'
,PitCorrosion as 'Pit corrosion'
,Locationofcorrosionofreinforcement as 'Location of corrosion of reinforcement'
,PoorConcrete as 'Poor concrete'
,Floreseffectedlocationno as 'Flores Effected Location No'
,DeflectionVisible as 'Deflection visible'
,Excessivevibrationisobserved as 'Excessive vibration observed'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,hitslabbyhammer as 'Sound due to hit slab by hammer'
,pondingofwater as 'Ponding of water'
,locationsofspotswhereconcretediscoloured as 'Locations where concrete discoloured'
,AnchorForCrossPreStressing as 'Anchor for cross prestressing'
,NumberofDamagedAnchorinaSpan as 'No of damaged anchors in a span'
,DescriptionofDamage as 'Damage description'
,DegreeofCorrosionoftheAnchorageend as 'Degree of corrosion of the anchorageend'
,DescriptionofDamageofDucts as 'Description of Damage of Ducts'
,NumberofLooseStrands as 'No of Loose strands'
,TotalNumberofStrandsateachAnchorage as 'Total no of strands at each anchorage'
,ElementinspectedbutnotMeasured as 'Element inspected but not measured'
,VerticalDeflectionofContilevertip as 'Vertical deflection of contilevertip'
,ModerateDeflection as 'Moderate deflection'
,ExcessiveDeflection as 'Excessive deflection'
,ConditionofJointBetweenDeckSlabandGirders as 'Condition of joint between deckslab and girders'
,dripcourseatedgofslab as 'Drip course at edge of slab'
,cs.[Description] as 'Slab Condition Severity'
,ce.[Description] as 'Slab Condition Extent'
,slb.Remarks
,S.[Description] as 'Season'
from BMS.DeckSlabCondition slb
INNER JOIN [BMS].[LocationDetails] ld ON slb.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=slb.SlabconditionExtent
LEFT OUTER JOIN bms.LKPTCrkType ct ON ct.CrackType=slb.Typeofcracks
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=slb.SlabConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=slb.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=slb.ConditionofPainting
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=slb.ConditionofSteelMembers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=slb.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,gc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,Lengthofcrack as 'Length of crack (m)'
,NumberofcracksNum as 'Number of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,Spalling as 'Spalling / Rusting (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,PoorConcrete as 'Poor Concrete / Steel (Sqm)'
,DeflectionVisible as 'Deflection Visible'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel numbers'
,AnchorForCrossPreStressing as 'Anchor For Cross Pre Stressing'
,NoOfanchordamagedinspan as 'Number of Damaged Anchor in a Span'
,DegreeofCorrosionatAnchorage as 'Degree of Corrosion of the Anchorage end'
,DescofDmgofDucts as 'Description for Damage of Ducts'
,NumberofLooseStrands as 'Number of Loose Strands'
,NoOfstrandsatanchorage as 'Number of Strands at each Anchorage'
,Inspectedbutnotmeasured as 'Element inspected but not Measured'
,SpallsinaSpan as 'Spalls in a Span'
,NumberOfSpallLocation as 'Number Of Spall Location'
,numberofBarsExposedandCorroded as 'number of Bars Exposed and Corroded'
,PercentageOfCorrosion as 'Percentage Of Corrosion '
,Floreseffectedlocationno as 'Number of locations in a span effected by efflorescence, dampness and leakage'
,cs.[Description] as 'Girder condition Severity'
,ce.[Description] as 'Girder condition Extent'
,gc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.GirderCondition gc
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON gc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON gc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=gc.GirderConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=gc.GirderConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=gc.conditionofconnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=gc.conditionofpaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=gc.conditionofsteelnumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=gc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,fc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment/Pier Number'
,AM.[Description] as 'Foundation Material Type'
,FoundationScourobserved as 'Foundation Scour observed'
,ScourDepth as 'Scour Depth (m)'
,FoundationSettlementisobserved as 'Foundation Settlement is observed'
,settlementobserved as 'settlement observed (m)'
,Cracking as 'Cracking (m)'
,Spalling as 'Spalling (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,Bulging as 'Bulging (Sqm)'
,PoorPointing as 'Poor Pointing (Sqm)'
,DeteriorationofBricksorStones as 'Deterioration of Bricks or Stones (Sqm)'
,damagedbedprotection as 'Observed Dislodgement and damage of River bed Protection work at foundation location'
,damageduetoflotingbodies as 'Description of damage due to impact of floating bodies'
,Probleamduetooverloading as 'Description of Problems due to overloading'
,LocationOfCracksConcrete as 'Location Of Cracks Concrete'
,NatureofCracksConcrete as 'Nature of Cracks Concrete'
,WidthofcracksConcrete as 'Width of cracks Concrete(mm)'
,LengthofCracksConcrete as 'Length of Cracks Concrete(mm)'
,PercentageOfVisualSurfaceCracked as 'Percentage Of Visual Surface Cracked'
,NumberofspallsLocationConcrete as 'Number of spalls Location Concrete'
,TotalAreaOfSpallingConcrete as 'Total Area Of Spalling Concrete(sqm)'
,Depthofspallingconcrete as 'Depth of spalling concrete(m)'
,PercentageofCorrosion as 'Percentage Of Corrosion to be measured with respect to bar Diameter'
,ElementInspectedbutnotmeasured as 'Element Inspected but not measured'
,ce.[Description] as 'Abutment Foundation Condition Extent'
,cs.[Description] as 'Abutment Foundation Condition Severity'
,cs1.[Description] as 'Pier Foundation Condition Severity'
,ce1.[Description] as 'Pier Foundation Condition Extent'
,fc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.FoundationCondition fc
INNER JOIN [BMS].[LocationDetails] ld ON fc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=fc.AbutmentFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=fc.AbutmentFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTCondExt ce1 ON ce1.CondExtType=fc.PierFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs1 ON cs1.CondSevType=fc.PierFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=fc.FoundationMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=fc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
END
ELSE IF @hType = 'MP'
BEGIN
select BridgeCode as 'Bridge Code'
,SurveyID as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,LengthofCrack as 'Length of cracks (m)'
,Noofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks 'Location of cracks'
,Spalling as 'Spalling'
,NoofBarsExposed as 'No of bars exposed'
,CorrosionofReinforcement as 'Corrosion of Reinforcement (sqm)'
,LocationofCorrosion as'Location of corrosion'
,PoorConcrete 'Poor concrete'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,cgc.Remarks
,S.[Description] as 'Season'
from BMS.CrossGirderCondition cgc
inner join BMS.LocationDetails ld on cgc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON cgc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=cgc.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=cgc.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=cgc.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=cgc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,dsc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,dst.[Description] as 'Deck surface material type'
,st.[Description] as 'Deck surface cracking type'
,CrackingCond as 'Cracking Condition'
,AreaofFineCracking as 'Area of fine cracking'
,AreaofWideCracking as 'Area of wide cracking'
,areaofsurfacecrack as 'Area of surface cracking'
,Potholes
,Ravelling
,totalareaofdepression as 'Total area of depression'
,CorrugationsRipples as 'Corrugation ripples'
,Spalling
,ReinforcementExposed as 'Reinforcement exposed'
,PoorConcrete as 'Poor concrete'
,Fp.[Description] as 'Footpath type'
,NatureOfDamage as 'Nature of damage'
,totalnumberofductsblocked as 'Total number of ducts blocked'
,FootpathDamagedPortion as 'footpath damaged portion'
,percentageoffootpathdamaged as 'percentage of footpath damaged'
,pondingofwater as 'ponding of water'
,cs.[Description] as 'Surface Condition Severity'
,ce.[Description] as 'Surface Condition Extent'
,dsc.Remarks
,S.[Description] as Season
from BMS.DeckSurfaceCondition dsc
INNER JOIN [BMS].[LocationDetails] ld ON dsc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=dsc.SurfaceConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=dsc.SurfaceConditionSeverity
LEFT OUTER JOIN BMS.LKPTSurfType st ON st.SurfType= dsc.DeckSurfaceCrackingType
LEFT OUTER JOIN bms.LKPTFPType ft ON ft.FPType=dsc.FootpathType
LEFT OUTER JOIN BMS.LKPTDeckSurfMaterType dst ON dst.DeckSurfMaterType= dsc.DeckSurfaceMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsc.Season
LEFT OUTER JOIN BMS.LKPTFPType fp on dsc.FootpathType = fp.FPType
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,drn.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,NoofspoutsfilledwithdebrisNum as 'No of spouts filled with debris'
,CorrosionofGrills as 'Corrosion of grills'
,NospoutswithoutgrillsNum as 'No of spouts without grills'
,PropercrossslopeinSuperStructure as 'Proper cross slope in super sturcture'
,OrientationofDrainagepipe as 'Orientation of drainage pipe'
,PipeMaterial as 'Pipe material'
,LeachingSpallingNearPipe as 'Leaching or spalling near pipe'
,noofspoutsendedatsoffit as 'No of spouts ended at soffit'
,Noofspoutpipesmissing as 'No of spout pipes missing'
,Pipeprojectionbelowsoffit as 'Pipe projection below soffit'
,collectionpitatdrainage as 'Collection pit at drainage'
,drn.Remarks
,S.[Description] as 'Season'
from BMS.DrainSpoutCondition drn
INNER JOIN [BMS].[LocationDetails] ld ON drn.BridgeCode = ld.BridgeID
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=drn.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,rc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,rt.[Description] as 'Railing type'
,Damagetoouter as 'Damage to outer'
,Looseordamagedfixings as 'Loose or damaged fixings'
,DeteriarationofpaintSqm as 'Deterioration of paint (Sqm)'
,NumberofpipesmissingNum as 'Number of pipes missing'
,Totallengthofmissingpipes as 'Total length of missing pipes'
,NumberofpostsmissingNum as 'Number of posts missing'
,Cracks
,DetailsofDamagedRailing as 'Details of Damaged Railing'
,DamagedCrashBarrier as 'Damaged Crash Barrier'
,Spalling
,LengthRequiredtotalreplacement as 'Length Required total replacement'
,cs.[Description] as 'Railing Condition Severity'
,ce.[Description] as 'Railing Condition Extent'
,rc.Remarks
,S.[Description] as 'Season'
from BMS.RailingCondition rc
INNER JOIN [BMS].[LocationDetails] ld ON rc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=rc.RailingConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=rc.RailingConditionSeverity
LEFT OUTER JOIN BMS.LKPTRailType rt ON rt.RailType=rc.RailingType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=rc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,jc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment or Pier No'
,et.[Description] as 'Expansion Joint type'
,Concretedamageatexpansionjoint as 'Concrete damage at expansion joint'
,Damageorcorrosiontometalparts as 'Damage or corrosion to metal parts'
,Damagetorubberwaterseals as 'Damage to rubber water seals'
,LooseorDamagedfixtures as 'Loose or damaged fixtures'
,Signsofleakageunderneaththedeck as 'Signs of leakage underneath the deck'
,DebrisorVegetationinjoint as 'Debris or vegetation in joint'
,CheckforProperVerticalAlignment as 'Check for proper vertical alignment'
,soundatexpjoint as 'Sound at joint'
,cs.[Description]as 'Joint Condition Severity'
,ce.[Description] as 'Joint Condition Extent'
,jc.Remarks
,S.[Description] as 'Season'
from BMS.JointCondition jc
INNER JOIN [BMS].[LocationDetails] ld ON jc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=jc.JointConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=jc.JointConditionSeverity
LEFT OUTER JOIN BMS.LKPTExpjtType et ON et.ExpjtType=jc.ExpansionJointType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=jc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
--AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,slb.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Types of Crack'
,Lengthofcrack as 'Length of crack (m)'
,Numberofcracks as 'No of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,NumberofSpalls as 'No of Spalls'
,Spalling
,DepthOfEachSpall as 'Depth of each spall'
,Noofbarsexposed as 'No of bars exposed'
,Corrosionofreinforcement as 'Corrosion or reinforcement'
,PercentageofCorrosion as 'Corrosion (%)'
,PitCorrosion as 'Pit corrosion'
,Locationofcorrosionofreinforcement as 'Location of corrosion of reinforcement'
,PoorConcrete as 'Poor concrete'
,Floreseffectedlocationno as 'Flores Effected Location No'
,DeflectionVisible as 'Deflection visible'
,Excessivevibrationisobserved as 'Excessive vibration observed'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel members'
,hitslabbyhammer as 'Sound due to hit slab by hammer'
,pondingofwater as 'Ponding of water'
,locationsofspotswhereconcretediscoloured as 'Locations where concrete discoloured'
,AnchorForCrossPreStressing as 'Anchor for cross prestressing'
,NumberofDamagedAnchorinaSpan as 'No of damaged anchors in a span'
,DescriptionofDamage as 'Damage description'
,DegreeofCorrosionoftheAnchorageend as 'Degree of corrosion of the anchorageend'
,DescriptionofDamageofDucts as 'Description of Damage of Ducts'
,NumberofLooseStrands as 'No of Loose strands'
,TotalNumberofStrandsateachAnchorage as 'Total no of strands at each anchorage'
,ElementinspectedbutnotMeasured as 'Element inspected but not measured'
,VerticalDeflectionofContilevertip as 'Vertical deflection of contilevertip'
,ModerateDeflection as 'Moderate deflection'
,ExcessiveDeflection as 'Excessive deflection'
,ConditionofJointBetweenDeckSlabandGirders as 'Condition of joint between deckslab and girders'
,dripcourseatedgofslab as 'Drip course at edge of slab'
,cs.[Description] as 'Slab Condition Severity'
,ce.[Description] as 'Slab Condition Extent'
,slb.Remarks
,S.[Description] as 'Season'
from BMS.DeckSlabCondition slb
INNER JOIN [BMS].[LocationDetails] ld ON slb.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=slb.SlabconditionExtent
LEFT OUTER JOIN bms.LKPTCrkType ct ON ct.CrackType=slb.Typeofcracks
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=slb.SlabConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=slb.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=slb.ConditionofPainting
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=slb.ConditionofSteelMembers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=slb.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select
BridgeCode
,ac.SurveyYear
,AbutmentNo
,SubStrIsSpalling
,SubStrVegJnts
,SubStrWpHolesBlocked
,SubStrCrckPercent
,DirtWallDfrmt
,DirtWallCrcks
,SubStrSpallingLocCnt
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckWidth
,DirtWallInspectedNtMsrd
,cs.Description as DirtWallCondSev
,cs.Description as DirtWallCondExt

,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,ac.Remarks
,SubStrCrckLen
,DirtWallRdlcrck
,DirtWallExsShrDfrmt
,SubStrIsCracked
,SubStrIsRCCExposed
,DSDmgedExpsionJnt
,DSDmgedApprchSlab
,SubStrRCCExposedDtls
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,SubStrMtrlLsJntCnt
,SubStrLseJntCnt
,SubStrInspectedNtMsrd
,scs.Description as SubstrCondSev
,sce.Description as SubstrCondExt
from BMS.AbutmentCondition ac
INNER JOIN BMS.LocationDetails ld on ac.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=ac.DirtWallCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=ac.DirtWallCondSev
LEFT OUTER JOIN BMS.LKPTCondExt sce ON ce.CondExtType=ac.SubstrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev scs ON cs.CondSevType=ac.SubstrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=ac.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=ac.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON ce.CondExtType=ac.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON cs.CondSevType=ac.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON ce.CondExtType=ac.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON cs.CondSevType=ac.DSApprchSlabCondSev
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=ac.CapMtrlType
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM1 ON AM1.AbutMaterialType=ac.AbutmentMaterialType
LEFT OUTER JOIN BMS.LKPTCrkType ct ON ac.SubStrCrckNature =ct.CrackType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=ac.Season
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)
-- AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage--,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,gc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,ct.[Description] as 'Type of cracks'
,Lengthofcrack as 'Length of crack (m)'
,NumberofcracksNum as 'Number of cracks'
,widthofcracks as 'Width of cracks (mm)'
,Locationofcracks as 'Location of cracks'
,Spalling as 'Spalling / Rusting (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,PoorConcrete as 'Poor Concrete / Steel (Sqm)'
,DeflectionVisible as 'Deflection Visible'
,lkc.[Description] as 'Condition of connections'
,lp.[Description] as 'Condition of paintings'
,ls.[Description] as 'Condition of steel numbers'
,AnchorForCrossPreStressing as 'Anchor For Cross Pre Stressing'
,NoOfanchordamagedinspan as 'Number of Damaged Anchor in a Span'
,DegreeofCorrosionatAnchorage as 'Degree of Corrosion of the Anchorage end'
,DescofDmgofDucts as 'Description for Damage of Ducts'
,NumberofLooseStrands as 'Number of Loose Strands'
,NoOfstrandsatanchorage as 'Number of Strands at each Anchorage'
,Inspectedbutnotmeasured as 'Element inspected but not Measured'
,SpallsinaSpan as 'Spalls in a Span'
,NumberOfSpallLocation as 'Number Of Spall Location'
,numberofBarsExposedandCorroded as 'number of Bars Exposed and Corroded'
,PercentageOfCorrosion as 'Percentage Of Corrosion '
,Floreseffectedlocationno as 'Number of locations in a span effected by efflorescence, dampness and leakage'
,cs.[Description] as 'Girder condition Severity'
,ce.[Description] as 'Girder condition Extent'
,gc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.GirderCondition gc
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON gc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCrkType ct ON gc.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=gc.GirderConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=gc.GirderConditionSeverity
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=gc.conditionofconnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=gc.conditionofpaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=gc.conditionofsteelnumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=gc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
select BridgeCode as 'Bridge Code'
,fc.SurveyYear as 'Survey year'
,SpanNo as 'Span No'
,AbutmentPierNumber as 'Abutment/Pier Number'
,AM.[Description] as 'Foundation Material Type'
,FoundationScourobserved as 'Foundation Scour observed'
,ScourDepth as 'Scour Depth (m)'
,FoundationSettlementisobserved as 'Foundation Settlement is observed'
,settlementobserved as 'settlement observed (m)'
,Cracking as 'Cracking (m)'
,Spalling as 'Spalling (Sqm)'
,NoOfbarsexposedNum as 'No. of bars exposed'
,Corrosionofreinforcement as 'Corrosion of reinforcement (Sqm)'
,Bulging as 'Bulging (Sqm)'
,PoorPointing as 'Poor Pointing (Sqm)'
,DeteriorationofBricksorStones as 'Deterioration of Bricks or Stones (Sqm)'
,damagedbedprotection as 'Observed Dislodgement and damage of River bed Protection work at foundation location'
,damageduetoflotingbodies as 'Description of damage due to impact of floating bodies'
,Probleamduetooverloading as 'Description of Problems due to overloading'
,LocationOfCracksConcrete as 'Location Of Cracks Concrete'
,NatureofCracksConcrete as 'Nature of Cracks Concrete'
,WidthofcracksConcrete as 'Width of cracks Concrete(mm)'
,LengthofCracksConcrete as 'Length of Cracks Concrete(mm)'
,PercentageOfVisualSurfaceCracked as 'Percentage Of Visual Surface Cracked'
,NumberofspallsLocationConcrete as 'Number of spalls Location Concrete'
,TotalAreaOfSpallingConcrete as 'Total Area Of Spalling Concrete(sqm)'
,Depthofspallingconcrete as 'Depth of spalling concrete(m)'
,PercentageofCorrosion as 'Percentage Of Corrosion to be measured with respect to bar Diameter'
,ElementInspectedbutnotmeasured as 'Element Inspected but not measured'
,ce.[Description] as 'Abutment Foundation Condition Extent'
,cs.[Description] as 'Abutment Foundation Condition Severity'
,cs1.[Description] as 'Pier Foundation Condition Severity'
,ce1.[Description] as 'Pier Foundation Condition Extent'
,fc.Remarks as 'Remarks'
,S.[Description] as 'Season'
from BMS.FoundationCondition fc
INNER JOIN [BMS].[LocationDetails] ld ON fc.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=fc.AbutmentFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=fc.AbutmentFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTCondExt ce1 ON ce1.CondExtType=fc.PierFoundationConditionExtent
LEFT OUTER JOIN BMS.LKPTCondSev cs1 ON cs1.CondSevType=fc.PierFoundationConditionSeverity
LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=fc.FoundationMaterialType
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=fc.Season
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)
AND Season = ISNULL(@season,Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,SpanNo)
END
END
END
GO
alter PROCEDURE [dbo].[GetspanConditionsGridByFilter]
--EXEC [dbo].[GetspanConditionsGridByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL,2019
--EXEC [dbo].[GetspanConditionsGridByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'pranusha', 'w',NULL,NULL,2019
--EXEC [dbo].[GetspanConditionsGridByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL,2019
--EXEC [dbo].[GetspanConditionsGridByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL,2019
(
@roadCode VARCHAR(100)=NULL,
@bridgeType VARCHAR(100) = NULL,
@bridgeCode VARCHAR(100)=NULL,
@season VARCHAR(50)=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,
@surveyYear VARCHAR(20) = NULL
)
AS
BEGIN
IF (@userType = 'H' and @hType is NULL)
BEGIN
SELECT [BridgeID] as 'BridgeCode', CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)',ld.[Direction],
--[LinkCode],[FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace], BrdgSupStrCrsGrdrCondid, hd.BridgeCode
ld.DateofInspection 'Date of Inspection', dsd.SurveyYear as 'Survey Year', dsd.SpanNo 'Span No',
--jc.AbutmentPierNumber 'Abutment Pier No',
S.[Description] as Season ,
lkptSev.[Description] as 'Surface condition severity',lkptExt.[Description]+'('+lkptExt.Remarks+')' as 'Surface condition extent',
lkptSevDSC.[Description] as 'Slab condition severity',lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as 'Slab condition extent',
lkptSevGC.[Description] as 'Girder condition severity',lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as 'Girder condition extent',
lkptSevJC.[Description] as 'Joint condition severity',lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as 'Joint condition extent',
lkptSevBC.[Description] as 'Bearing condition severity',lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as 'Bearing condition extent'
-- hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
--hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
--hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
--ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
-- , 'Approved' ApprovalStatus ,hd.Season as 'seasonID' ,eo
FROM [BMS].[LocationDetails] ld
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON dsd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN [BMS].[CrossGirderCondition] hd ON HD.BridgeCode =ld.BridgeID and dsd.SpanNo = hd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = dsc.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsd.SurfaceConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and dsd.Season = JC.Season and dsd.SurveyYear = JC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and dsd.SpanNo = GC.SpanNo and dsd.Season = GC.Season and dsd.SurveyYear = GC.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and dsd.SurveyYear = BC.SurveyYear-- and dsd.Season = BC.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
--LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
--LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
--LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
--LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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)
AND (Case WHEN dsd.Season IS NULL THEN DSC.Season else dsd.Season end) = ISNULL(@season,dsd.Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,dsd.SpanNo)
END
ELSE IF ((@userType = 'C' OR @userType = 'W') and @hType is NULL)
BEGIN
SELECT [BridgeID] as 'BridgeCode', CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)',ld.[Direction],
--[LinkCode],[FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace], BrdgSupStrCrsGrdrCondid, hd.BridgeCode
ld.DateofInspection 'Date of Inspection', dsd.SurveyYear as 'Survey Year', dsd.SpanNo 'Span No',
--jc.AbutmentPierNumber 'Abutment Pier No',
S.[Description] as Season ,
lkptSev.[Description] as 'Surface condition severity',lkptExt.[Description]+'('+lkptExt.Remarks+')' as 'Surface condition extent',
lkptSevDSC.[Description] as 'Slab condition severity',lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as 'Slab condition extent',
lkptSevGC.[Description] as 'Girder condition severity',lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as 'Girder condition extent',
lkptSevJC.[Description] as 'Joint condition severity',lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as 'Joint condition extent',
lkptSevBC.[Description] as 'Bearing condition severity',lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as 'Bearing condition extent'
-- hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
--hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
--hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
--ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
-- , 'Approved' ApprovalStatus ,hd.Season as 'seasonID' ,eo
FROM [BMS].[LocationDetails] ld
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON dsd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN [BMS].[CrossGirderCondition] hd ON HD.BridgeCode =ld.BridgeID and dsd.SpanNo = hd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = dsc.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsd.SurfaceConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and dsd.Season = JC.Season and dsd.SurveyYear = JC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and dsd.SpanNo = GC.SpanNo and dsd.Season = GC.Season and dsd.SurveyYear = GC.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and dsd.SurveyYear = BC.SurveyYear-- and dsd.Season = BC.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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)
AND (Case WHEN dsd.Season IS NULL THEN DSC.Season else dsd.Season end) = ISNULL(@season,dsd.Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,dsd.SpanNo)
END
ELSE IF (@userType = 'D' and @hType is NULL)
BEGIN
SELECT [BridgeID] as 'BridgeCode', CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)',ld.[Direction],
--[LinkCode],[FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace], BrdgSupStrCrsGrdrCondid, hd.BridgeCode
ld.DateofInspection 'Date of Inspection', dsd.SurveyYear as 'Survey Year', dsd.SpanNo 'Span No',
--jc.AbutmentPierNumber 'Abutment Pier No',
S.[Description] as Season ,
lkptSev.[Description] as 'Surface condition severity',lkptExt.[Description]+'('+lkptExt.Remarks+')' as 'Surface condition extent',
lkptSevDSC.[Description] as 'Slab condition severity',lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as 'Slab condition extent',
lkptSevGC.[Description] as 'Girder condition severity',lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as 'Girder condition extent',
lkptSevJC.[Description] as 'Joint condition severity',lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as 'Joint condition extent',
lkptSevBC.[Description] as 'Bearing condition severity',lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as 'Bearing condition extent'
-- hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
--hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
--hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
--ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
-- , 'Approved' ApprovalStatus ,hd.Season as 'seasonID' ,eo
FROM [BMS].[LocationDetails] ld
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON dsd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN [BMS].[CrossGirderCondition] hd ON HD.BridgeCode =ld.BridgeID and dsd.SpanNo = hd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = dsc.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsd.SurfaceConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and dsd.Season = JC.Season and dsd.SurveyYear = JC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and dsd.SpanNo = GC.SpanNo and dsd.Season = GC.Season and dsd.SurveyYear = GC.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and dsd.SurveyYear = BC.SurveyYear-- and dsd.Season = BC.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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)
AND (Case WHEN dsd.Season IS NULL THEN DSC.Season else dsd.Season end) = ISNULL(@season,dsd.Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,dsd.SpanNo)
END
ELSE
BEGIN
IF @hType = 'C'
BEGIN
SELECT [BridgeID] as 'BridgeCode', CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)',ld.[Direction],
--[LinkCode],[FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace], BrdgSupStrCrsGrdrCondid, hd.BridgeCode
ld.DateofInspection 'Date of Inspection', dsd.SurveyYear as 'Survey Year', dsd.SpanNo 'Span No',
--jc.AbutmentPierNumber 'Abutment Pier No',
S.[Description] as Season ,
lkptSev.[Description] as 'Surface condition severity',lkptExt.[Description]+'('+lkptExt.Remarks+')' as 'Surface condition extent',
lkptSevDSC.[Description] as 'Slab condition severity',lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as 'Slab condition extent',
lkptSevGC.[Description] as 'Girder condition severity',lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as 'Girder condition extent',
lkptSevJC.[Description] as 'Joint condition severity',lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as 'Joint condition extent',
lkptSevBC.[Description] as 'Bearing condition severity',lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as 'Bearing condition extent'
-- hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
--hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
--hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
--ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
-- , 'Approved' ApprovalStatus ,hd.Season as 'seasonID' ,eo
FROM [BMS].[LocationDetails] ld
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON dsd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN [BMS].[CrossGirderCondition] hd ON HD.BridgeCode =ld.BridgeID and dsd.SpanNo = hd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = dsc.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsd.SurfaceConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and dsd.Season = JC.Season and dsd.SurveyYear = JC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and dsd.SpanNo = GC.SpanNo and dsd.Season = GC.Season and dsd.SurveyYear = GC.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and dsd.SurveyYear = BC.SurveyYear-- and dsd.Season = BC.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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)
AND (Case WHEN dsd.Season IS NULL THEN DSC.Season else dsd.Season end) = ISNULL(@season,dsd.Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,dsd.SpanNo)
END
ELSE IF @hType = 'D'
BEGIN
SELECT [BridgeID] as 'BridgeCode', CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)',ld.[Direction],
--[LinkCode],[FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace], BrdgSupStrCrsGrdrCondid, hd.BridgeCode
ld.DateofInspection 'Date of Inspection', dsd.SurveyYear as 'Survey Year', dsd.SpanNo 'Span No',
--jc.AbutmentPierNumber 'Abutment Pier No',
S.[Description] as Season ,
lkptSev.[Description] as 'Surface condition severity',lkptExt.[Description]+'('+lkptExt.Remarks+')' as 'Surface condition extent',
lkptSevDSC.[Description] as 'Slab condition severity',lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as 'Slab condition extent',
lkptSevGC.[Description] as 'Girder condition severity',lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as 'Girder condition extent',
lkptSevJC.[Description] as 'Joint condition severity',lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as 'Joint condition extent',
lkptSevBC.[Description] as 'Bearing condition severity',lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as 'Bearing condition extent'
-- hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
--hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
--hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
--ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
-- , 'Approved' ApprovalStatus ,hd.Season as 'seasonID' ,eo
FROM [BMS].[LocationDetails] ld
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON dsd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN [BMS].[CrossGirderCondition] hd ON HD.BridgeCode =ld.BridgeID and dsd.SpanNo = hd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = dsc.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsd.SurfaceConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and dsd.Season = JC.Season and dsd.SurveyYear = JC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and dsd.SpanNo = GC.SpanNo and dsd.Season = GC.Season and dsd.SurveyYear = GC.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and dsd.SurveyYear = BC.SurveyYear-- and dsd.Season = BC.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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)
AND (Case WHEN dsd.Season IS NULL THEN DSC.Season else dsd.Season end) = ISNULL(@season,dsd.Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,dsd.SpanNo)
END
ELSE IF @hType = 'W'
BEGIN
SELECT [BridgeID] as 'BridgeCode', CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)',ld.[Direction],
--[LinkCode],[FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace], BrdgSupStrCrsGrdrCondid, hd.BridgeCode
ld.DateofInspection 'Date of Inspection', dsd.SurveyYear as 'Survey Year', dsd.SpanNo 'Span No',
--jc.AbutmentPierNumber 'Abutment Pier No',
S.[Description] as Season ,
lkptSev.[Description] as 'Surface condition severity',lkptExt.[Description]+'('+lkptExt.Remarks+')' as 'Surface condition extent',
lkptSevDSC.[Description] as 'Slab condition severity',lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as 'Slab condition extent',
lkptSevGC.[Description] as 'Girder condition severity',lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as 'Girder condition extent',
lkptSevJC.[Description] as 'Joint condition severity',lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as 'Joint condition extent',
lkptSevBC.[Description] as 'Bearing condition severity',lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as 'Bearing condition extent'
-- hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
--hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
--hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
--ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
-- , 'Approved' ApprovalStatus ,hd.Season as 'seasonID' ,eo
FROM [BMS].[LocationDetails] ld
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON dsd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN [BMS].[CrossGirderCondition] hd ON HD.BridgeCode =ld.BridgeID and dsd.SpanNo = hd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = dsc.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsd.SurfaceConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and dsd.Season = JC.Season and dsd.SurveyYear = JC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and dsd.SpanNo = GC.SpanNo and dsd.Season = GC.Season and dsd.SurveyYear = GC.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and dsd.SurveyYear = BC.SurveyYear-- and dsd.Season = BC.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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 TypeoftheBridge = ISNULL(@bridgeType,TypeoftheBridge)
AND BridgeID = ISNULL(@bridgeCode,ld.BridgeID)
AND (Case WHEN dsd.Season IS NULL THEN DSC.Season else dsd.Season end) = ISNULL(@season,dsd.Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,dsd.SpanNo)
END
ELSE IF @hType = 'MLA'
BEGIN
SELECT [BridgeID] as 'BridgeCode', CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)',ld.[Direction],
--[LinkCode],[FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace], BrdgSupStrCrsGrdrCondid, hd.BridgeCode
ld.DateofInspection 'Date of Inspection', dsd.SurveyYear as 'Survey Year', dsd.SpanNo 'Span No',
--jc.AbutmentPierNumber 'Abutment Pier No',
S.[Description] as Season ,
lkptSev.[Description] as 'Surface condition severity',lkptExt.[Description]+'('+lkptExt.Remarks+')' as 'Surface condition extent',
lkptSevDSC.[Description] as 'Slab condition severity',lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as 'Slab condition extent',
lkptSevGC.[Description] as 'Girder condition severity',lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as 'Girder condition extent',
lkptSevJC.[Description] as 'Joint condition severity',lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as 'Joint condition extent',
lkptSevBC.[Description] as 'Bearing condition severity',lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as 'Bearing condition extent'
-- hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
--hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
--hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
--ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
-- , 'Approved' ApprovalStatus ,hd.Season as 'seasonID' ,eo
FROM [BMS].[LocationDetails] ld
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON dsd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN [BMS].[CrossGirderCondition] hd ON HD.BridgeCode =ld.BridgeID and dsd.SpanNo = hd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = dsc.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsd.SurfaceConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and dsd.Season = JC.Season and dsd.SurveyYear = JC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and dsd.SpanNo = GC.SpanNo and dsd.Season = GC.Season and dsd.SurveyYear = GC.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and dsd.SurveyYear = BC.SurveyYear-- and dsd.Season = BC.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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)
AND (Case WHEN dsd.Season IS NULL THEN DSC.Season else dsd.Season end) = ISNULL(@season,dsd.Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,dsd.SpanNo)
END
ELSE IF @hType = 'MP'
BEGIN
SELECT [BridgeID] as 'BridgeCode', CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainage (km)',ld.[Direction],
--[LinkCode],[FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace], BrdgSupStrCrsGrdrCondid, hd.BridgeCode
ld.DateofInspection 'Date of Inspection', dsd.SurveyYear as 'Survey Year', dsd.SpanNo 'Span No',
--jc.AbutmentPierNumber 'Abutment Pier No',
S.[Description] as Season ,
lkptSev.[Description] as 'Surface condition severity',lkptExt.[Description]+'('+lkptExt.Remarks+')' as 'Surface condition extent',
lkptSevDSC.[Description] as 'Slab condition severity',lkptExt.[Description]+'('+lkptExtdsc.Remarks+')' as 'Slab condition extent',
lkptSevGC.[Description] as 'Girder condition severity',lkptExt.[Description]+'('+lkptExtGC.Remarks+')' as 'Girder condition extent',
lkptSevJC.[Description] as 'Joint condition severity',lkptExt.[Description]+'('+lkptExtJC.Remarks+')' as 'Joint condition extent',
lkptSevBC.[Description] as 'Bearing condition severity',lkptExt.[Description]+'('+lkptExtBC.Remarks+')' as 'Bearing condition extent'
-- hd.TypeofCracks, hd.LengthofCrack, hd.Noofcracks, hd.widthofcracks,
--hd.Locationofcracks, hd.Spalling, hd.NoofBarsExposed, hd.CorrosionofReinforcement, hd.LocationofCorrosion, hd.PoorConcrete,
--hd.ConditionofConnections, hd.ConditionofPaintings, hd.ConditionofSteelNumbers, hd.Remarks,
--ct.[Description] 'TypeofCracksDescription',lkc.[Description] 'ConditionofConnectionsDescription',ls.[Description] 'ConditionofPaintingsDescription',lp.[Description] 'StlMemCondTypeDescription'
-- , 'Approved' ApprovalStatus ,hd.Season as 'seasonID' ,eo
FROM [BMS].[LocationDetails] ld
LEFT OUTER JOIN [BMS].[DeckSurfaceCondition] dsd ON dsd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN [BMS].[CrossGirderCondition] hd ON HD.BridgeCode =ld.BridgeID and dsd.SpanNo = hd.SpanNo and dsd.Season = hd.Season and dsd.SurveyYear = hd.SurveyID
LEFT OUTER JOIN BMS.LKPTSeverity lkptSev ON dsd.SurfaceConditionSeverity=lkptSev.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExt ON dsd.SurfaceConditionExtent=lkptExt.ExtentCode
LEFT OUTER JOIN [BMS].DeckSlabCondition DSC ON ld.BridgeID =DSC.Bridgecode and dsd.SpanNo = DSC.SpanNo and dsd.Season = dsc.Season and dsd.SurveyYear = DSC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevDSC ON dsc.SlabConditionSeverity=lkptSevDSC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtDSC ON dsd.SurfaceConditionExtent=lkptExtDSC.ExtentCode
LEFT OUTER JOIN [BMS].JointCondition JC ON ld.BridgeID =JC.Bridgecode and dsd.SpanNo = JC.SpanNo and dsd.Season = JC.Season and dsd.SurveyYear = JC.SurveyYear
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevJC ON JC.JointConditionSeverity=lkptSevJC.SeverityCode
LEFT OUTER JOIN BMS.LKPTExtent lkptExtJC ON JC.JointConditionExtent= lkptExtJC.ExtentCode
LEFT OUTER JOIN [BMS].[GirderCondition] GC ON ld.BridgeID =GC.Bridgecode and dsd.SpanNo = GC.SpanNo and dsd.Season = GC.Season and dsd.SurveyYear = GC.SurveyYear
LEFT OUTER JOIN BMS.LKPTExtent lkptExtGC ON GC.GirderConditionExtent= lkptExtGC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevGC ON GC.GirderConditionSeverity=lkptSevGC.SeverityCode
LEFT OUTER JOIN [BMS].BearingCondition BC ON ld.BridgeID =BC.Bridgecode and BC.AbtmntNo = JC.AbutmentPierNumber and dsd.SurveyYear = BC.SurveyYear-- and dsd.Season = BC.Season
LEFT OUTER JOIN BMS.LKPTExtent lkptExtBC ON BC.BearingCondExt= lkptExtBC.ExtentCode
LEFT OUTER JOIN BMS.LKPTSeverity lkptSevBC ON BC.BearingCondSev=lkptSevBC.SeverityCode
LEFT OUTER JOIN BMS.LKPTCrkType ct ON hd.TypeofCracks=ct.CrackType
LEFT OUTER JOIN BMS.LKPTConnectCond lkc ON lkc.ConnectCondType=hd.ConditionofConnections
LEFT OUTER JOIN BMS.LKPTPaintCond lp ON lp.PaintCondType=hd.ConditionofPaintings
LEFT OUTER JOIN BMS.LKPTStlMemCond ls ON ls.StlMemCondType=hd.ConditionofSteelNumbers
LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=dsd.Season
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)
AND (Case WHEN dsd.Season IS NULL THEN DSC.Season else dsd.Season end) = ISNULL(@season,dsd.Season)
AND ld.SurveyYear=ISNULL(@surveyYear,ld.SurveyYear)
ORDER by lm.IsPilot desc, ld.RoadCode,ld.Chainage,Convert(int,dsd.SpanNo)
END
END
END
GO
alter PROCEDURE [BMS].[BridgeConditionSpanWise]
--[BMS].[BridgeConditionSpanWise] 2019,'D',NULL,'thejaswit','Rajkot R&B Circle-2',NULL,NULL,'null'
@SurveyYear NVARCHAR(100),
@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
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', rm.RoadCategoryCode,LD.RoadCode,rm.[Name] AS 'RoadName'
,LD.LinkCode,LD.Chainage ,LD.DateofInspection,LD.BridgeID,LD.YearofConstruction,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.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 C.CirclesName = IsNULL(@CName,C.CirclesName)
and LD.BridgeID=ISNULL(@BridgeCode,LD.BridgeID)
and LD.SurveyYear=ISNULL(@SurveyYear,LD.SurveyYear)
ORDER BY D.DivisionName,rm.RoadCategoryCode,LD.RoadCode,LD.BridgeID,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.LinkCode
INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode
inner 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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.LinkCode
INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode
inner 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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionExtent=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.LinkCode
INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode
inner 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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.LinkCode
INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode
inner 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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.LinkCode
INNER JOIN NM.roadmaster rm ON lm.RoadCode = rm.roadcode
inner 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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.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,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.DateofInspection,LD.BridgeID,LD.YearofConstruction ,Convert(int,DC.SpanNo) as 'SpanNo'
--,ASE.[Description] as 'CondSev',AEX.[Description] as 'CondExt'
,BSE.[Description] as 'BearingConditionSeverity',BEX.[Description] as 'BearingConditionExtent'
,DSE.[Description] as 'SlabConditionSeverity',DEX.[Description] as 'SlabconditionExtent'
,DCSE.[Description] as 'SurfaceConditionSeverity',DCEX.[Description] as 'SurfaceConditionExtent'
,FSE.[Description] as 'OverallCondSev',FEX.[Description] as 'OverallCondExt'
,PISE.[Description] as 'PierFoundationConditionSeverity',PIEX.[Description] as 'PierFoundationConditionExtent'
,GSE.[Description] as 'GirderConditionSeverity',GEX.[Description] as 'GirderConditionExtent'
,JSE.[Description] as 'JointConditionSeverity',JEX.[Description] as 'JointConditionExtent'
,PSE.[Description] as 'PierConditionSeverity',PEX.[Description] as 'PierConditionExtent'
,PWSE.[Description] as 'WorksConditionSeverity',PWEX.[Description] as 'WorksConditionExtent'
,RSE.[Description] as 'RailingConditionSeverity',REX.[Description] as 'RailingConditionExtent'
,WSE.[Description] as 'CondSev',WEX.[Description] as 'CondExt'
from BMS.LocationDetails LD
inner join [BMS].[DeckSlabCondition] DC on LD.BridgeID=DC.BridgeCode
inner join [BMS].[LKPTSeverity] DSE on DC.SlabConditionSeverity=DSE.SeverityCode
inner join [BMS].[LKPTExtent] DEX on DC.SlabconditionExtent=DEX.ExtentCode
left join [BMS].[AbutmentCondition] AC on LD.BridgeID=AC.BridgeCode --and DC.spanNo=AC.spanNo
--left join [BMS].[LKPTSeverity] ASE on AC.CondSev=ASE.SeverityCode
--left join [BMS].[LKPTExtent] AEX on AC.CondExt=AEX.ExtentCode
inner join [BMS].[DeckSurfaceCondition] DSC on LD.BridgeID=DSC.BridgeCode and DC.spanNo=DSC.spanNo
inner join [BMS].[LKPTSeverity] DCSE on DSC.SurfaceConditionSeverity=DCSE.SeverityCode
inner join [BMS].[LKPTExtent] DCEX on DSC.SurfaceConditionExtent = DCEX.ExtentCode
left join [BMS].[PierCondition] PC on LD.BridgeID = PC.BridgeCode-- and DC.spanNo = PC.spanNo
left join [BMS].[LKPTSeverity] PSE on PC.SubStrCondSev = PSE.SeverityCode
left join [BMS].[LKPTExtent] PEX on PC.SubStrCondExt = PEX.ExtentCode
left join [BMS].[FoundationCondition] AFC on AC.BridgeCode = AFC.BridgeCode -- and AC.spanNo=AFC.SpanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] FSE on AFC.AbutmentFoundationConditionSeverity = FSE.SeverityCode
left join [BMS].[LKPTExtent] FEX on AFC.AbutmentFoundationConditionExtent = FEX.ExtentCode
left join [BMS].[FoundationCondition] PFC on PC.BridgeCode = PFC.BridgeCode and DC.spanNo=PFC.spanNo --and (AC.AbutmentNo = FC.AbutmentPierNumber or PC.AbutmentPierNumber = FC.AbutmentPierNumber)
left join [BMS].[LKPTSeverity] PISE on PFC.PierFoundationConditionSeverity=PISE.SeverityCode
left join [BMS].[LKPTExtent] PIEX on PFC.PierFoundationConditionExtent=PIEX.ExtentCode
left join [BMS].[GirderCondition] GC on LD.BridgeID=GC.BridgeCode and DC.spanNo=GC.spanNo
left join [BMS].[LKPTSeverity] GSE on GC.GirderConditionSeverity=GSE.SeverityCode
left join [BMS].[LKPTExtent] GEX on GC.GirderConditionExtent=GEX.ExtentCode
inner join [BMS].[JointCondition] JC on LD.BridgeID=JC.BridgeCode and DC.spanNo=JC.spanNo
inner join [BMS].[LKPTSeverity] JSE on JC.JointConditionSeverity=JSE.SeverityCode
inner join [BMS].[LKPTExtent] JEX on JC.JointConditionExtent=JEX.ExtentCode
left join [BMS].[BearingCondition] BC on LD.BridgeID=BC.BridgeCode and PC.PierNo=BC.AbtmntNo
left join [BMS].[LKPTSeverity] BSE on BC.BearingCondSev=BSE.SeverityCode
left join [BMS].[LKPTExtent] BEX on BC.BearingCondExt=BEX.ExtentCode
left join [BMS].[ProtectionWorksCondition] PWC on LD.BridgeID=PWC.BridgeCode and DC.spanNo=1
left join [BMS].[LKPTSeverity] PWSE on PWC.WorksConditionSeverity=PWSE.SeverityCode
left join [BMS].[LKPTExtent] PWEX on PWC.WorksConditionExtent=PWEX.ExtentCode
inner join [BMS].[RailingCondition] RC on LD.BridgeID=RC.BridgeCode and DC.spanNo=RC.spanNo
inner join [BMS].[LKPTSeverity] RSE on RC.RailingConditionSeverity=RSE.SeverityCode
inner join [BMS].[LKPTExtent] REX on RC.RailingConditionExtent=REX.ExtentCode
left join [BMS].[WallCondition] WC on LD.BridgeID=WC.BridgeCode and DC.spanNo=WC.spanNo
left join [BMS].[LKPTSeverity] WSE on WC.WallConditionSeverity=WSE.SeverityCode
left join [BMS].[LKPTExtent] WEX on WC.WallConditionExtent=WEX.ExtentCode
INNER JOIN NM.linkmaster lm ON lm.LinkCode = LD.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,SpanNo
End
END
GO
ALTER PROCEDURE [dbo].[GetPierConditionByFilter]
-- exec [dbo].[GetPierConditionByFilter] NULL,NULL,NULL,NULL,NULL,'krish', NULL,NULL,NULL
--EXEC [dbo].[GetPierConditionByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'satya', 'H',NULL,NULL,2019
--EXEC [dbo].[GetPierConditionByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'pranusha', 'w',NULL,NULL,2019
--EXEC [dbo].[GetPierConditionByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'demogen', 'C',NULL,NULL,2019
--EXEC [dbo].[GetPierConditionByFilter] NULL,NULL,NULL,NULL,NULL,NULL,'div', 'D',NULL,NULL,2019
(
@roadCode VARCHAR(100)=NULL,
@bridgeType VARCHAR(100) = NULL,
@bridgeCode VARCHAR(100)=NULL,
@season bit=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
,@surveyYear VARCHAR(20) = NULL
)
AS
BEGIN
IF (@userType = 'H' and @hTypeVal IS NULL)
BEGIN
SELECT
[LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgSubStrPierCondid, BridgeCode, hd.SurveyYear,
PierNo
,RCCCracking
,SubStrIsSpalling
,SubStrRCCExposedDtls
,SubStrCrckPercent
,SubStrLseJntCnt
,SubStrMtrlLsJntCnt
,SubStrSpiltLocCnt
,SubStrVegJnts
,SubStrPlstrCond
,SubStrLseStonesLocCnt
,cs.Description as SubStrCondSev
,ce.Description as SubStrCondExt
,hd.Remarks
,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,PierCapCrcklength
,PierCapCrckWidth
,PierCapCrckPercent
,PierCapIsSpalling
,PierCapSpallingArea
,PierCapSpallingAvgDepth
,PierCapIsRCCExposed
,PierCapInspectedNtMsrd
,pcs.Description as PierCapCondSev
,pce.Description as PierCapCondExt
,SubStrIsCracked
,SubStrCrckLength
,SubStrCrckWidth
,CT.Description AS SubStrCrckNature
,SubStrCrckLoc
,SubStrSpallingLocCnt
,DSDmgedExpsionJnt
,SubStrIsRCCExposed
,SubStrInspectedNtMsrd
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,DSDmgedApprchSlab
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
, CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus' -- ,hd.Season as 'seasonID' ,S.Description as Season
FROM [BMS].[PierCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.SubStrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.SubStrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON pce.CondExtType=hd.PierCapCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON pcs.CondSevType=hd.PierCapCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON fce.CondExtType=hd.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON fcs.CondSevType=hd.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON dece.CondExtType=hd.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON decs.CondSevType=hd.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON dace.CondExtType=hd.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON dacs.CondSevType=hd.DSApprchSlabCondSev
LEFT OUTER JOIN bms.LKPTCrkType CT ON CT.CrackType=HD.SubStrCrckNature
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=hd.PierCapMaterialType
--LEFT OUTER JOIN BMS.LKPTAbutWallRailMaterType AWR ON AWR.AbutWallRailMaterType=hd.PierMaterialType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
IF ((@userType = 'C' OR @userType = 'W') and @hTypeVal IS NULL)
BEGIN
SELECT
[LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgSubStrPierCondid, BridgeCode, hd.SurveyYear,
PierNo
,RCCCracking
,SubStrIsSpalling
,SubStrRCCExposedDtls
,SubStrCrckPercent
,SubStrLseJntCnt
,SubStrMtrlLsJntCnt
,SubStrSpiltLocCnt
,SubStrVegJnts
,SubStrPlstrCond
,SubStrLseStonesLocCnt
,cs.Description as SubStrCondSev
,ce.Description as SubStrCondExt
,hd.Remarks
,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,PierCapCrcklength
,PierCapCrckWidth
,PierCapCrckPercent
,PierCapIsSpalling
,PierCapSpallingArea
,PierCapSpallingAvgDepth
,PierCapIsRCCExposed
,PierCapInspectedNtMsrd
,pcs.Description as PierCapCondSev
,pce.Description as PierCapCondExt
,SubStrIsCracked
,SubStrCrckLength
,SubStrCrckWidth
,CT.Description AS SubStrCrckNature
,SubStrCrckLoc
,SubStrSpallingLocCnt
,DSDmgedExpsionJnt
,SubStrIsRCCExposed
,SubStrInspectedNtMsrd
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,DSDmgedApprchSlab
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
, CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus' -- ,hd.Season as 'seasonID' ,S.Description as Season
FROM [BMS].[PierCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.SubStrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.SubStrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON pce.CondExtType=hd.PierCapCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON pcs.CondSevType=hd.PierCapCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON fce.CondExtType=hd.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON fcs.CondSevType=hd.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON dece.CondExtType=hd.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON decs.CondSevType=hd.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON dace.CondExtType=hd.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON dacs.CondSevType=hd.DSApprchSlabCondSev
LEFT OUTER JOIN bms.LKPTCrkType CT ON CT.CrackType=HD.SubStrCrckNature
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=hd.PierCapMaterialType
--LEFT OUTER JOIN BMS.LKPTAbutWallRailMaterType AWR ON AWR.AbutWallRailMaterType=hd.PierMaterialType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE IF (@userType = 'D' and @hTypeVal IS NULL)
BEGIN
SELECT
[LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgSubStrPierCondid, BridgeCode, hd.SurveyYear,
PierNo
,RCCCracking
,SubStrIsSpalling
,SubStrRCCExposedDtls
,SubStrCrckPercent
,SubStrLseJntCnt
,SubStrMtrlLsJntCnt
,SubStrSpiltLocCnt
,SubStrVegJnts
,SubStrPlstrCond
,SubStrLseStonesLocCnt
,cs.Description as SubStrCondSev
,ce.Description as SubStrCondExt
,hd.Remarks
,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,PierCapCrcklength
,PierCapCrckWidth
,PierCapCrckPercent
,PierCapIsSpalling
,PierCapSpallingArea
,PierCapSpallingAvgDepth
,PierCapIsRCCExposed
,PierCapInspectedNtMsrd
,pcs.Description as PierCapCondSev
,pce.Description as PierCapCondExt
,SubStrIsCracked
,SubStrCrckLength
,SubStrCrckWidth
,CT.Description AS SubStrCrckNature
,SubStrCrckLoc
,SubStrSpallingLocCnt
,DSDmgedExpsionJnt
,SubStrIsRCCExposed
,SubStrInspectedNtMsrd
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,DSDmgedApprchSlab
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
, CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus' -- ,hd.Season as 'seasonID' ,S.Description as Season
FROM [BMS].[PierCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.SubStrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.SubStrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON pce.CondExtType=hd.PierCapCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON pcs.CondSevType=hd.PierCapCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON fce.CondExtType=hd.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON fcs.CondSevType=hd.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON dece.CondExtType=hd.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON decs.CondSevType=hd.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON dace.CondExtType=hd.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON dacs.CondSevType=hd.DSApprchSlabCondSev
LEFT OUTER JOIN bms.LKPTCrkType CT ON CT.CrackType=HD.SubStrCrckNature
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=hd.PierCapMaterialType
--LEFT OUTER JOIN BMS.LKPTAbutWallRailMaterType AWR ON AWR.AbutWallRailMaterType=hd.PierMaterialType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE
BEGIN
IF @hType = 'C'
BEGIN
SELECT
[LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgSubStrPierCondid, BridgeCode, hd.SurveyYear,
PierNo
,RCCCracking
,SubStrIsSpalling
,SubStrRCCExposedDtls
,SubStrCrckPercent
,SubStrLseJntCnt
,SubStrMtrlLsJntCnt
,SubStrSpiltLocCnt
,SubStrVegJnts
,SubStrPlstrCond
,SubStrLseStonesLocCnt
,cs.Description as SubStrCondSev
,ce.Description as SubStrCondExt
,hd.Remarks
,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,PierCapCrcklength
,PierCapCrckWidth
,PierCapCrckPercent
,PierCapIsSpalling
,PierCapSpallingArea
,PierCapSpallingAvgDepth
,PierCapIsRCCExposed
,PierCapInspectedNtMsrd
,pcs.Description as PierCapCondSev
,pce.Description as PierCapCondExt
,SubStrIsCracked
,SubStrCrckLength
,SubStrCrckWidth
,CT.Description AS SubStrCrckNature
,SubStrCrckLoc
,SubStrSpallingLocCnt
,DSDmgedExpsionJnt
,SubStrIsRCCExposed
,SubStrInspectedNtMsrd
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,DSDmgedApprchSlab
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
, CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus' -- ,hd.Season as 'seasonID' ,S.Description as Season
FROM [BMS].[PierCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.SubStrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.SubStrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON pce.CondExtType=hd.PierCapCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON pcs.CondSevType=hd.PierCapCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON fce.CondExtType=hd.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON fcs.CondSevType=hd.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON dece.CondExtType=hd.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON decs.CondSevType=hd.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON dace.CondExtType=hd.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON dacs.CondSevType=hd.DSApprchSlabCondSev
LEFT OUTER JOIN bms.LKPTCrkType CT ON CT.CrackType=HD.SubStrCrckNature
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=hd.PierCapMaterialType
--LEFT OUTER JOIN BMS.LKPTAbutWallRailMaterType AWR ON AWR.AbutWallRailMaterType=hd.PierMaterialType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE IF @hType = 'D'
BEGIN
SELECT
[LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgSubStrPierCondid, BridgeCode, hd.SurveyYear,
PierNo
,RCCCracking
,SubStrIsSpalling
,SubStrRCCExposedDtls
,SubStrCrckPercent
,SubStrLseJntCnt
,SubStrMtrlLsJntCnt
,SubStrSpiltLocCnt
,SubStrVegJnts
,SubStrPlstrCond
,SubStrLseStonesLocCnt
,cs.Description as SubStrCondSev
,ce.Description as SubStrCondExt
,hd.Remarks
,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,PierCapCrcklength
,PierCapCrckWidth
,PierCapCrckPercent
,PierCapIsSpalling
,PierCapSpallingArea
,PierCapSpallingAvgDepth
,PierCapIsRCCExposed
,PierCapInspectedNtMsrd
,pcs.Description as PierCapCondSev
,pce.Description as PierCapCondExt
,SubStrIsCracked
,SubStrCrckLength
,SubStrCrckWidth
,CT.Description AS SubStrCrckNature
,SubStrCrckLoc
,SubStrSpallingLocCnt
,DSDmgedExpsionJnt
,SubStrIsRCCExposed
,SubStrInspectedNtMsrd
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,DSDmgedApprchSlab
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
, CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus' -- ,hd.Season as 'seasonID' ,S.Description as Season
FROM [BMS].[PierCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.SubStrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.SubStrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON pce.CondExtType=hd.PierCapCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON pcs.CondSevType=hd.PierCapCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON fce.CondExtType=hd.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON fcs.CondSevType=hd.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON dece.CondExtType=hd.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON decs.CondSevType=hd.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON dace.CondExtType=hd.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON dacs.CondSevType=hd.DSApprchSlabCondSev
LEFT OUTER JOIN bms.LKPTCrkType CT ON CT.CrackType=HD.SubStrCrckNature
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=hd.PierCapMaterialType
--LEFT OUTER JOIN BMS.LKPTAbutWallRailMaterType AWR ON AWR.AbutWallRailMaterType=hd.PierMaterialType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE IF @hType = 'W'
BEGIN
SELECT
[LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgSubStrPierCondid, BridgeCode, hd.SurveyYear,
PierNo
,RCCCracking
,SubStrIsSpalling
,SubStrRCCExposedDtls
,SubStrCrckPercent
,SubStrLseJntCnt
,SubStrMtrlLsJntCnt
,SubStrSpiltLocCnt
,SubStrVegJnts
,SubStrPlstrCond
,SubStrLseStonesLocCnt
,cs.Description as SubStrCondSev
,ce.Description as SubStrCondExt
,hd.Remarks
,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,PierCapCrcklength
,PierCapCrckWidth
,PierCapCrckPercent
,PierCapIsSpalling
,PierCapSpallingArea
,PierCapSpallingAvgDepth
,PierCapIsRCCExposed
,PierCapInspectedNtMsrd
,pcs.Description as PierCapCondSev
,pce.Description as PierCapCondExt
,SubStrIsCracked
,SubStrCrckLength
,SubStrCrckWidth
,CT.Description AS SubStrCrckNature
,SubStrCrckLoc
,SubStrSpallingLocCnt
,DSDmgedExpsionJnt
,SubStrIsRCCExposed
,SubStrInspectedNtMsrd
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,DSDmgedApprchSlab
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
, CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus' -- ,hd.Season as 'seasonID' ,S.Description as Season
FROM [BMS].[PierCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.SubStrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.SubStrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON pce.CondExtType=hd.PierCapCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON pcs.CondSevType=hd.PierCapCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON fce.CondExtType=hd.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON fcs.CondSevType=hd.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON dece.CondExtType=hd.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON decs.CondSevType=hd.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON dace.CondExtType=hd.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON dacs.CondSevType=hd.DSApprchSlabCondSev
LEFT OUTER JOIN bms.LKPTCrkType CT ON CT.CrackType=HD.SubStrCrckNature
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=hd.PierCapMaterialType
--LEFT OUTER JOIN BMS.LKPTAbutWallRailMaterType AWR ON AWR.AbutWallRailMaterType=hd.PierMaterialType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE IF @hType = 'MLA'
BEGIN
SELECT
[LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgSubStrPierCondid, BridgeCode, hd.SurveyYear,
PierNo
,RCCCracking
,SubStrIsSpalling
,SubStrRCCExposedDtls
,SubStrCrckPercent
,SubStrLseJntCnt
,SubStrMtrlLsJntCnt
,SubStrSpiltLocCnt
,SubStrVegJnts
,SubStrPlstrCond
,SubStrLseStonesLocCnt
,cs.Description as SubStrCondSev
,ce.Description as SubStrCondExt
,hd.Remarks
,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,PierCapCrcklength
,PierCapCrckWidth
,PierCapCrckPercent
,PierCapIsSpalling
,PierCapSpallingArea
,PierCapSpallingAvgDepth
,PierCapIsRCCExposed
,PierCapInspectedNtMsrd
,pcs.Description as PierCapCondSev
,pce.Description as PierCapCondExt
,SubStrIsCracked
,SubStrCrckLength
,SubStrCrckWidth
,CT.Description AS SubStrCrckNature
,SubStrCrckLoc
,SubStrSpallingLocCnt
,DSDmgedExpsionJnt
,SubStrIsRCCExposed
,SubStrInspectedNtMsrd
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,DSDmgedApprchSlab
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
, CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus' -- ,hd.Season as 'seasonID' ,S.Description as Season
FROM [BMS].[PierCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.SubStrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.SubStrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON pce.CondExtType=hd.PierCapCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON pcs.CondSevType=hd.PierCapCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON fce.CondExtType=hd.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON fcs.CondSevType=hd.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON dece.CondExtType=hd.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON decs.CondSevType=hd.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON dace.CondExtType=hd.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON dacs.CondSevType=hd.DSApprchSlabCondSev
LEFT OUTER JOIN bms.LKPTCrkType CT ON CT.CrackType=HD.SubStrCrckNature
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=hd.PierCapMaterialType
--LEFT OUTER JOIN BMS.LKPTAbutWallRailMaterType AWR ON AWR.AbutWallRailMaterType=hd.PierMaterialType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
ELSE IF @hType = 'MP'
BEGIN
SELECT
[LocationId],ld.[RoadCode],CONVERT ( DECIMAL(18,3) ,(Chainage/1000.00)) as 'Chainagekm',ld.[LinkCode], ld.[Direction]
,[BridgeID], [FunctionofBridge], [TypeoftheBridge], [YearofConstruction], [Nameofnearbyplace],
BrdgSubStrPierCondid, BridgeCode, hd.SurveyYear,
PierNo
,RCCCracking
,SubStrIsSpalling
,SubStrRCCExposedDtls
,SubStrCrckPercent
,SubStrLseJntCnt
,SubStrMtrlLsJntCnt
,SubStrSpiltLocCnt
,SubStrVegJnts
,SubStrPlstrCond
,SubStrLseStonesLocCnt
,cs.Description as SubStrCondSev
,ce.Description as SubStrCondExt
,hd.Remarks
,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,PierCapCrcklength
,PierCapCrckWidth
,PierCapCrckPercent
,PierCapIsSpalling
,PierCapSpallingArea
,PierCapSpallingAvgDepth
,PierCapIsRCCExposed
,PierCapInspectedNtMsrd
,pcs.Description as PierCapCondSev
,pce.Description as PierCapCondExt
,SubStrIsCracked
,SubStrCrckLength
,SubStrCrckWidth
,CT.Description as SubStrCrckNature
,SubStrCrckLoc
,SubStrSpallingLocCnt
,DSDmgedExpsionJnt
,SubStrIsRCCExposed
,SubStrInspectedNtMsrd
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,DSDmgedApprchSlab
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
, CASE WHEN hd.[BridgeCode] IS NOT NULL THEN 'Approved' ELSE 'New' END 'ApprovalStatus' -- ,hd.Season as 'seasonID' ,S.Description as Season
FROM [BMS].[PierCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.SubStrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.SubStrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON pce.CondExtType=hd.PierCapCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON pcs.CondSevType=hd.PierCapCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON fce.CondExtType=hd.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON fcs.CondSevType=hd.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON dece.CondExtType=hd.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON decs.CondSevType=hd.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON dace.CondExtType=hd.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON dacs.CondSevType=hd.DSApprchSlabCondSev
LEFT OUTER JOIN bms.LKPTCrkType CT ON CT.CrackType=HD.SubStrCrckNature
--LEFT OUTER JOIN BMS.LKPTAbutMaterial AM ON AM.AbutMaterialType=hd.PierCapMaterialType
--LEFT OUTER JOIN BMS.LKPTAbutWallRailMaterType AWR ON AWR.AbutWallRailMaterType=hd.PierMaterialType
--LEFT OUTER JOIN dbo.LKPTSeason S ON s.Code=hd.Season
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 hd.BridgeCode = ISNULL(@bridgeCode,hd.BridgeCode)
--AND hd.Season = ISNULL(@season,hd.Season)
AND hd.SurveyYear=ISNULL(@surveyYear,hd.SurveyYear)
END
END
END
GO
alter PROCEDURE [dbo].[GetPierConditionByBridgeCode]
(
@bridgeCode VARCHAR(100)=NULL,
@surveyYear VARCHAR(100)=NULL,
@spanNo VARCHAR(10) = NULL,
@tableFlag VARCHAR(10)=NULL
)
AS
BEGIN
IF @tableFlag = 'M'
BEGIN
SELECT
BrdgSubStrPierCondid
,BridgeCode
,hd.SurveyYear
,PierNo
,RCCCracking
,SubStrIsSpalling
,SubStrRCCExposedDtls
,SubStrCrckPercent
,SubStrLseJntCnt
,SubStrMtrlLsJntCnt
,SubStrSpiltLocCnt
,SubStrVegJnts
,SubStrPlstrCond
,SubStrLseStonesLocCnt
,cs.Description as SubStrCondSev
,ce.Description as SubStrCondExt
,hd.Remarks
,SubStrSpallingArea
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionIsRiverBedDmgd
,FndtionInspectedNtMsrd
,FndtionflotingbodiesImpct
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,PierCapCrcklength
,PierCapCrckWidth
,PierCapCrckPercent
,PierCapIsSpalling
,PierCapSpallingArea
,PierCapSpallingAvgDepth
,PierCapIsRCCExposed
,PierCapInspectedNtMsrd
,pcs.Description as PierCapCondSev
,pce.Description as PierCapCondExt
,SubStrIsCracked
,SubStrCrckLength
,SubStrCrckWidth
,CT.Description as SubStrCrckNature
,SubStrCrckLoc
,SubStrSpallingLocCnt
,DSDmgedExpsionJnt
,SubStrIsRCCExposed
,SubStrInspectedNtMsrd
,decs.Description as DSExpsionJntCondSev
,dece.Description as DSExpsionJntCondExt
,DSDmgedApprchSlab
,dacs.Description as DSApprchSlabCondSev
,dace.Description as DSApprchSlabCondExt
,DSApprchSlabCondExt
FROM [BMS].[PierCondition] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.SubStrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.SubStrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON pce.CondExtType=hd.PierCapCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON pcs.CondSevType=hd.PierCapCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON fce.CondExtType=hd.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON fcs.CondSevType=hd.FndtionCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dece ON dece.CondExtType=hd.DSExpsionJntCondExt
LEFT OUTER JOIN BMS.LKPTCondSev decs ON decs.CondSevType=hd.DSExpsionJntCondSev
LEFT OUTER JOIN BMS.LKPTCondExt dace ON dace.CondExtType=hd.DSApprchSlabCondExt
LEFT OUTER JOIN BMS.LKPTCondSev dacs ON dacs.CondSevType=hd.DSApprchSlabCondSev
LEFT OUTER JOIN bms.LKPTCrkType CT ON CT.CrackType=HD.SubStrCrckNature
WHERE BridgeCode = @bridgeCode
AND hd.SurveyYear = @surveyYear
END
ELSE
BEGIN
SELECT
[BrdgSubStrPierCondid], [BridgeCode], hd.[SurveyYear], [SpanNo], [AbutmentPierNumber], [PierCapMaterialType], [RCCCracking], [RCCSpalling],
[RCCNoofbarsexposed], [RCCCorrosionofreinforcement], [PoorConcrete], [Vegetationoverthecap], [TotalPercentageofsurfacecracked],
[PierMaterialType], [MasonryNoofbarsexposed], [MasonryCracking], [MasonryBulging], [PoorPointing], [DeteriorationofBricksorStones],
[DamagetoRCCPCCcoping], [WeepHolesblocked], [Numberlocationofloosejoints], [lossofjointmaterialiden], [shiftedstonesorbr],
[plasterovermasonryAbutment], [crackingdamaged], [DetailofvegetationgrowthatJoints], [Impactduetofloatingbodies], [lossofjointmaterial],
[Conditionofplasterovermasonrypier], [NumberLocationoflooseorshiftedstones], [PierConditionSeverity], [PierConditionExtent], hd.[Remarks], [CondCode]
FROM [BMS].[PierCondition_Staging] hd
LEFT OUTER JOIN [BMS].[LocationDetails] ld ON hd.BridgeCode = ld.BridgeID
WHERE BridgeCode = @bridgeCode
AND hd.SurveyYear = @surveyYear
END
END
GO
CREATE PROCEDURE GetPierBearingConditionByFilter
(
@roadCode VARCHAR(100)=NULL,
@bridgeType VARCHAR(100) = NULL,
@bridgeCode VARCHAR(100)=NULL,
@season bit=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
,@surveyYear VARCHAR(20) = NULL
)
AS
BEGIN
SELECT PierBearingConditionid
,BridgeCode
,SurveyYear
,PierNo
,CmprsBulgSides
,SurfaceCrck
,Rdlcrck
,ExsShrDfrmt
,DfrmtBearingShp
,AnchorBoltsDamaged
,bearingFreeMove
,FrgnMtrlExists
,RlrsRckrsPropPositn
,NutLooseLocCnt
,BearingInspectedNtMsrd
,cs.Description as BearingCondSev
,ce.Description as BearingCondExt
,CrckInBearingsPdstl
,CrckCnt
,CT.Description as CrckType
,CrckWidth
,PdstlsInspectedNtMsrd
,pcs.Description as PdstlsCondSev
,pce.Description as PdstlsCondExt
,CrcksInSmrstr
,SplDlmnCncrt
,ExpCrrdReinfrcmnt
,Anypartbroken
,DisldgmntBcklng
,PaintDamage
,LoosenutsBoltsCrackedweldetc
,SmRstrInspectedNtMsrd
,fcs.Description as SmRstrCondSev
,fcs.Description as SmRstrCondExt
,Remarks
FROM bms.PierBearingCondition hd
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.BearingCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.BearingCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON pce.CondExtType=hd.PdstlsCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON pcs.CondSevType=hd.PdstlsCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON fce.CondExtType=hd.SmRstrCondSev
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON fcs.CondSevType=hd.SmRstrCondExt
LEFT OUTER JOIN bms.LKPTCrkType CT ON CT.CrackType=HD.CrckType
END
GO
CREATE PROCEDURE GetReturnWallWingWallByFilter
(
@roadCode VARCHAR(100)=NULL,
@bridgeType VARCHAR(100) = NULL,
@bridgeCode VARCHAR(100)=NULL,
@season bit=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
,@surveyYear VARCHAR(20) = NULL
)
AS
BEGIN
SELECT ReturnWallWingWallid
,BridgeCode
,SurveyYear
,AbutmentNo
,SubStrRWPartialCollapse
,SubStrIsCracked
,SubStrCrckLen
,SubStrCrckWidth
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckPercent
,SubStrIsSpalling
,SubStrSpallingArea
,SubStrSpallingLocCnt
,SubStrRCCExposed
,SubStrRCCExposedDtls
,SubStrLseJntCnt
,SubStrMtrlLsJntCnt
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,SubStrVegJnts
,SubStrInspectedNtMsrd
,cs.Description as SubStrCondSev
,ce.Description as SubStrCondExt
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionflotingbodiesImpct
,FndtionInspectedNtMsrd
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,Remarks
FROM [BMS].[ReturnWall_WingWall] RW
LEFT OUTER JOIN bms.LKPTCrkType ct ON ct.CrackType=rw.SubStrCrckNature
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=rw.SubStrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=rw.SubStrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=rw.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=rw.FndtionCondSev
END
GO
CREATE PROCEDURE GetReturnWallWingWallGridByFilter
(
@roadCode VARCHAR(100)=NULL,
@bridgeType VARCHAR(100) = NULL,
@bridgeCode VARCHAR(100)=NULL,
@season VARCHAR(50)=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,
@surveyYear VARCHAR(20) = NULL
)
AS
BEGIN
SELECT ReturnWallWingWallid
,BridgeCode
,SurveyYear
,AbutmentNo
,SubStrRWPartialCollapse
,SubStrIsCracked
,SubStrCrckLen
,SubStrCrckWidth
,SubStrCrckLoc
,ct.Description as SubStrCrckNature
,SubStrCrckPercent
,SubStrIsSpalling
,SubStrSpallingArea
,SubStrSpallingLocCnt
,SubStrRCCExposed
,SubStrRCCExposedDtls
,SubStrLseJntCnt
,SubStrMtrlLsJntCnt
,SubStrLseStonesLocCnt
,SubStrPlstrCond
,SubStrSpiltLocCnt
,SubStrVegJnts
,SubStrInspectedNtMsrd
,cs.Description as SubStrCondSev
,ce.Description as SubStrCondExt
,FndtionIsScoursObsv
,FndtionScoursDepth
,FndtionIsStlmnt
,FndtionStlmntDepth
,FndtionflotingbodiesImpct
,FndtionInspectedNtMsrd
,fcs.Description as FndtionCondSev
,fce.Description as FndtionCondExt
,Remarks
FROM [BMS].[ReturnWall_WingWall] RW
LEFT OUTER JOIN bms.LKPTCrkType ct ON ct.CrackType=rw.SubStrCrckNature
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=rw.SubStrCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=rw.SubStrCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON ce.CondExtType=rw.FndtionCondExt
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON cs.CondSevType=rw.FndtionCondSev
WHERE BridgeCode=ISNULL(@bridgeCode,BridgeCode)
END
GO
CREATE PROCEDURE GetPierBearingConditionGridByFilter
(
@roadCode VARCHAR(100)=NULL,
@bridgeType VARCHAR(100) = NULL,
@bridgeCode VARCHAR(100)=NULL,
@season VARCHAR(50)=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,
@surveyYear VARCHAR(20) = NULL
)
AS
BEGIN
SELECT PierBearingConditionid
,BridgeCode
,SurveyYear
,PierNo
,CmprsBulgSides
,SurfaceCrck
,Rdlcrck
,ExsShrDfrmt
,DfrmtBearingShp
,AnchorBoltsDamaged
,bearingFreeMove
,FrgnMtrlExists
,RlrsRckrsPropPositn
,NutLooseLocCnt
,BearingInspectedNtMsrd
,cs.Description as BearingCondSev
,ce.Description as BearingCondExt
,CrckInBearingsPdstl
,CrckCnt
,CT.Description as CrckType
,CrckWidth
,PdstlsInspectedNtMsrd
,pcs.Description as PdstlsCondSev
,pce.Description as PdstlsCondExt
,CrcksInSmrstr
,SplDlmnCncrt
,ExpCrrdReinfrcmnt
,Anypartbroken
,DisldgmntBcklng
,PaintDamage
,LoosenutsBoltsCrackedweldetc
,SmRstrInspectedNtMsrd
,fcs.Description as SmRstrCondSev
,fcs.Description as SmRstrCondExt
,Remarks
FROM bms.PierBearingCondition hd
LEFT OUTER JOIN BMS.LKPTCondExt ce ON ce.CondExtType=hd.BearingCondExt
LEFT OUTER JOIN BMS.LKPTCondSev cs ON cs.CondSevType=hd.BearingCondSev
LEFT OUTER JOIN BMS.LKPTCondExt pce ON pce.CondExtType=hd.PdstlsCondExt
LEFT OUTER JOIN BMS.LKPTCondSev pcs ON pcs.CondSevType=hd.PdstlsCondSev
LEFT OUTER JOIN BMS.LKPTCondExt fce ON fce.CondExtType=hd.SmRstrCondSev
LEFT OUTER JOIN BMS.LKPTCondSev fcs ON fcs.CondSevType=hd.SmRstrCondExt
LEFT OUTER JOIN bms.LKPTCrkType CT ON CT.CrackType=HD.CrckType
WHERE BridgeCode=ISNULL(@bridgeCode,BridgeCode)
END
(5-5/10)