У меня есть следующий cte:
WITH cte AS
(
SELECT
c.ParentIDNo,
c.Category,
c.ChildCategory,
c.WSWebProductNameIDNo,
c.IDNo,
0 AS Level,
CAST('/' + c.Category AS VARCHAR(1000)) as CteName
FROM WSWebCategory as c
WHERE c.ParentIDNo IS NULL
UNION ALL
SELECT
t.ParentIDNo,
t.Category,
t.ChildCategory,
t.WSWebProductNameIDNo,
t.IDNo,
cte.Level + 1 AS Level,
CAST(cte.CteName + '/' + t.ChildCategory AS VARCHAR(1000)) AS CteName
FROM WSWebCategory t
INNER JOIN cte ON t.ParentIDNo = cte.IDNo
)
SELECT *, REPLICATE('----', Level) + CteName as CteName FROM cte
ORDER BY cte.CteName
, который дает мне список вроде:
/Apparatus
----/Apparatus/Autoclaves
--------/Apparatus/Autoclaves/ALL-AMERICAN Portable Sterilizers (WAFCO)
--------/Apparatus/Autoclaves/Autoclave Accessories
------------/Apparatus/Autoclaves/Autoclave Accessories/Clavies® Autoclave Gloves (Bel-Art Scienceware)
------------/Apparatus/Autoclaves/Autoclave Accessories/Grabbit™ Temp Mitts (Heathrow Scientific)
------------/Apparatus/Autoclaves/Autoclave Accessories/Odo-Clave® Deodorant Pads (Bel-Art Scienceware)
--------/Apparatus/Autoclaves/Autoclave Bags
------------/Apparatus/Autoclaves/Autoclave Bags/Autoclavable Biohazard Disposal Bags (Bel-Art Scienceware)
------------/Apparatus/Autoclaves/Autoclave Bags/Autoclavable Biohazard Disposal Bags (Gosselin)
------------/Apparatus/Autoclaves/Autoclave Bags/Autoclavable Hi-Temp Biohazard Disposal Bags (Bel-Art Scienceware)
------------/Apparatus/Autoclaves/Autoclave Bags/Chex-All® II Sterilization Pouches (Propper)
------------/Apparatus/Autoclaves/Autoclave Bags/Clavies® Autoclave Gloves (Bel-Art Scienceware)
------------/Apparatus/Autoclaves/Autoclave Bags/Clavies® Bag Holder (Bel-Art Scienceware)
------------/Apparatus/Autoclaves/Autoclave Bags/Clavies® General Purpose Autoclavable Bags (Bel-Art Scienceware)
------------/Apparatus/Autoclaves/Autoclave Bags/Poxygrid® Biohazard Bag Holder (Bel-Art Scienceware)
но мне нужно множество вложенных html-списков:
<ul>
<li>Apparatus
<ul>
<li>Autoclaves
<ul>
<li>ALL-AMERICAN Portable Sterilizers (WAFCO)</li>
<li>Autoclave Accessories
<ul>
<li>Clavies® Autoclave Gloves (Bel-Art Scienceware)</li>
<li>Grabbit™ Temp Mitts (Heathrow Scientific)</li>
<li>Odo-Clave® Deodorant Pads (Bel-Art Scienceware) </li>
</ul>
</li>
<li>Autoclave Bags
<ul>
<li>Autoclavable Biohazard Disposal Bags (Bel-Art Scienceware)</li>
<li>Autoclavable Biohazard Disposal Bags (Gosselin)</li>
<li>Autoclavable Hi-Temp Biohazard Disposal Bags (Bel-Art Scienceware)</li>
<li>Chex-All® II Sterilization Pouches (Propper)</li>
<li>Clavies® Autoclave Gloves (Bel-Art Scienceware)</li>
<li>Clavies® Bag Holder (Bel-Art Scienceware)</li>
<li>Clavies® General Purpose Autoclavable Bags (Bel-Art Scienceware)</li>
<li>Poxygrid® Biohazard Bag Holder (Bel-Art Scienceware)</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
Я в тупик, как это сделать!