[dba-SQLServer] Cross posted as got brain freeze

Paul Hartland paul.hartland at googlemail.com
Thu Dec 13 01:09:03 CST 2018


To all,

Hopefully I will start seeing some messages come through soon, I have a
problem where I just know the answer should be pretty simple but seem to
have brain freeze.  I have the following table (sorry for any wrapping etc)

SECTION START_POINT END_POINT DEFECT_CODE
SecA         0.00                 100.00 RUT
SecA         50.00         140.00 FAT
SecA         10.00          20.00 POTHOLE
SecA         60.00          70.00 POTHOLE

and I need to produce something like below

SECTION START_POINT END_POINT DEFECT_CODES_XML
SecA         0.00                  10.00 <DefectCodes>RUT</DefectCodes>
SecA         10.00          20.00 <DefectCodes>RUT,POTHOLE</DefectCodes>
SecA         20.00          50.00 <DefectCodes>RUT</DefectCodes>
SecA         50.00          60.00 <DefectCodes>RUT,FAT</DefectCodes>
SecA         60.00          70.00 <DefectCodes>RUT,POTHOLE,FAT</DefectCodes>
SecA         70.00         100.00 <DefectCodes>RUT,FAT</DefectCodes>
SecA        100.00         140.00 <DefectCodes>FAT</DefectCodes>

As you can see the start and end points can cross over etc, I think the
main problem I am having is creating the start & end points from the
initial four rows, any help greatly appreciated before I succumb to
starting the Christmas spirit (whisky) earlier than I have
anticipated.......

Many many many thanks and Christmas wishes to everyone for the help.

-- 
Paul Hartland
paul.hartland at googlemail.com


More information about the dba-SQLServer mailing list