문제

SSRS 인스턴스에 대한 모든 보고서를 업데이트 할 프로젝트가 있으며 모든 보고서 목록을 Excel로 가져갈 것이라고 생각하여 각 보고서를 업데이트 할 때 표시 할 수 있다고 생각했습니다. 쉽게 생각했습니다. 나는 그것을 자주 사용하지 않지만 XML은 이것에 빌려주는 것 같았습니다. 나는 다음과 같은 것을 가질 것입니다.

<Server>
  <ReportFolder>
    <ReportFolder>
      <Report>
      </Report>
      <Report>
      </Report>
    </ReportFolder>
    <Report>
    </Report>
    <Report>
    </Report>
    <Report>
    </Report>
  </ReportFolder>
  <ReportFolder>
  </ReportFolder>
</Server>

카탈로그 테이블은 내 데이터 소스였으며 itemId와 parentId가 있으므로 객체와 계층 구조를 식별 할 수 있지만 XML 양식으로 전체 서버를 얻을 수 없으므로 폴더 (이름 또는 이름 또는 itemid) 그러나 전체 서버는 아닙니다. Where itemid = 1234 라인을 꺼내면 다음과 같은 것을 얻습니다.

<Server>
  <ReportFolder>
  </ReportFolder>
  <ReportFolder>
  </ReportFolder>
  <ReportFolder>
  </ReportFolder>
    <Report>
    </Report>
    <Report>
    </Report>
    <Report>
    </Report>
    <Report>
    </Report>
    <Report>
    </Report>  
</Server>

나는 CTE의 XML Auto, XML 명시 적 시도를 시도했으며 이제 XML로 지금까지 내 분리가 정당하다고 느끼고 있습니다!

XML 형식의 전체 (최대 4 레벨)의 계층 구조를 얻는 방법이 있습니까?

이것은 XML과 관련이없는 것입니까? 나는 막 다른 골목으로 잘못 변신 했습니까?

도움이 되었습니까?

해결책

좋은 소식과 나쁜 소식. 좋은 소식이 있습니다.

CREATE FUNCTION [dbo].[GetReportTree](@ItemId uniqueidentifier)
RETURNS XML
BEGIN RETURN 
  (SELECT   ca.ItemId AS '@ItemId',
            ca.Name AS '@Name',
            ca.Type AS '@Type',
            dbo.GetReportTree(ca.ItemId)
   FROM dbo.Catalog ca
   WHERE (@ItemId IS NULL AND ParentId IS NULL) OR ParentID=@ItemId
   FOR XML PATH('CatalogItem'), TYPE)
END

SELECT dbo.[GetReportTree](NULL)   

다음과 같은 계층 구조를 생성합니다.

<CatalogItem Name="" Type="1">
  <CatalogItem Name="ScrumTest" Type="1">
    <CatalogItem Name="(Hidden) Delta Report Small" Type="2" />
    <CatalogItem Name="(Hidden) Product Burndown Chart Small" Type="2" />
    <CatalogItem Name="(Hidden) Product Cumulative Flow Small" Type="2" />
    <CatalogItem Name="(Hidden) Sprint Burndown Chart Small" Type="2" />
    <CatalogItem Name="All Product Backlog Items" Type="2" />
    <CatalogItem Name="All Sprint Backlog Items" Type="2" />
    <CatalogItem Name="All Sprints" Type="2" />
    <CatalogItem Name="Current Sprint Status" Type="2" />
    <CatalogItem Name="Delta Report" Type="2" />
    <CatalogItem Name="Engineering Reports" Type="1">
      <CatalogItem Name="(Hidden) Bug History Chart Small" Type="2" />
      <CatalogItem Name="Bug Count" Type="2" />
      <CatalogItem Name="Bug History Chart" Type="2" />
      <CatalogItem Name="Bug Priority Chart" Type="2" />
    </CatalogItem>
    <CatalogItem Name="Impediment Report" Type="2" />
    <CatalogItem Name="Product Backlog Composition" Type="2" />
    <CatalogItem Name="Product Burndown Chart" Type="2" />
    <CatalogItem Name="Product Cumulative Flow" Type="2" />
    <CatalogItem Name="Retrospective Report" Type="2" />

나쁜 소식은 보고서 서버에 "ReportTree"기능을 추가하지 않고 할 수 있는지 확실하지 않다는 것입니다. 따라서 해당 서버에 대한 액세스에 따라 다릅니다. 데이터베이스에서 기능을 작동시킬 수 있습니다. 시도하지 않았습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top