1
에 사용 JSON 텍스트로 포맷 할 수 없습니다 :열 표현과 데이터 소스 내가이 쿼리를 JSON 절
<xml>
<StoryData>
<UserStoryId>141204</UserStoryId>
<Description>Customer can see the applicable discount on the quote and change in premium.</Description>
<Summary>Customer can see the applicable discount on the quote and change in premium.</Summary>
<UserStoryID>141204</UserStoryID>
<ProjectId>23040</ProjectId>
<AnalysisOutcome>Ambiguities found</AnalysisOutcome>
<AssignedTo>ankit.k.arora</AssignedTo>
<RequirementAnalysisId>5901</RequirementAnalysisId>
<RequirementId>141204</RequirementId>
<VagueWordsArray>
<VagueWord>and</VagueWord>
</VagueWordsArray>
<VagueWordsArray>
<VagueWord>applicable</VagueWord>
</VagueWordsArray>
<SuggestionData>
<ContentText>Customer can see the applicable discount on the quote and change in premium.</ContentText>
<Explanation>Suggests that you are combining requirements. Requirements that contain conjunctions/disjunctions (AND/OR) are dangerous and can lead to downstream problems in defining scope of the requirement.</Explanation>
<Suggestion>Keep each requirement in a single sentence.</Suggestion>
<Summary>Customer can see the applicable discount on the quote and change in premium.</Summary>
<VagueTypeText>Not Standard</VagueTypeText>
<VagueWord>and</VagueWord>
</SuggestionData>
<SuggestionData>
<ContentText>Customer can see the applicable discount on the quote and change in premium.</ContentText>
<Explanation>Can be interpreted in different ways by different people.</Explanation>
<Suggestion>Include the precise definition in the glossary.</Suggestion>
<Summary>Customer can see the applicable discount on the quote and change in premium.</Summary>
<VaguePhrase>applicable discount</VaguePhrase>
<VagueTypeText>Not Defined</VagueTypeText>
<VagueWord>applicable</VagueWord>
</SuggestionData>
</StoryData>
<StoryData>
<UserStoryId>1400235</UserStoryId>
<Description>story 1</Description>
<Summary>undefined</Summary>
<UserStoryID>1400235</UserStoryID>
<ProjectId>23040</ProjectId>
<AnalysisOutcome>Rejected</AnalysisOutcome>
<AssignedTo>[email protected]</AssignedTo>
<RequirementAnalysisId>5958</RequirementAnalysisId>
<RequirementId>1400235</RequirementId>
<VagueWordsArray>
<VagueWord>and</VagueWord>
</VagueWordsArray>
<VagueWordsArray>
<VagueWord>or</VagueWord>
</VagueWordsArray>
<VagueWordsArray>
<VagueWord>should</VagueWord>
</VagueWordsArray>
<SuggestionData>
<ContentText>Story should or and not fail</ContentText>
<Explanation>Suggests that you are combining requirements. Requirements that contain conjunctions/disjunctions (AND/OR) are dangerous and can lead to downstream problems in defining scope of the requirement.</Explanation>
<Suggestion>Keep each requirement in a single sentence.</Suggestion>
<SuggestionList />
<Summary>undefined</Summary>
<VagueTypeText>Not Standard</VagueTypeText>
<VagueWord>and</VagueWord>
</SuggestionData>
<SuggestionData>
<ContentText>Story should or and not fail</ContentText>
<Explanation>Suggests that you are combining requirements. Requirements that contain conjunctions/disjunctions (AND/OR) are dangerous and can lead to downstream problems in defining scope of the requirement.</Explanation>
<Suggestion>Keep each requirement in a single sentence.</Suggestion>
<SuggestionList />
<Summary>undefined</Summary>
<VagueTypeText>Not Standard</VagueTypeText>
<VagueWord>or</VagueWord>
</SuggestionData>
<SuggestionData>
<ContentText>Story should or and not fail</ContentText>
<Explanation>Is often ambiguous, or inappropriate. Some readers will interpret these as optional or advisory, others as required.</Explanation>
<Suggestion>Use 'shall/must/will' for requirements,</Suggestion>
<SuggestionList>shall,must,will</SuggestionList>
<Summary>undefined</Summary>
<VagueTypeText>Not Standard</VagueTypeText>
<VagueWord>should</VagueWord>
</SuggestionData>
</StoryData>
</xml>
내가 :이 쿼리는이 XML을 반환
;WITH cte AS
(
SELECT
US.Description,
US.Title Summary,
ISNULL(US.MyWizardUserStoryId,'')UserStoryID,
A.RequirementId,ISNULL(US.ProjectId,'')ProjectId,
--(case when A.AnalysisOutcome='Found' then 'Ambiguous' else 'Non Ambiguous' end)
CASE WHEN ISNULL(A.AnalysisOutcome,'')='' THEN 'Analysis Pending'
WHEN ISNULL(A.AnalysisOutcome,'')='Found' THEN 'Ambiguities found'
WHEN ISNULL(A.AnalysisOutcome,'')='Not Found' THEN 'No Ambiguities'
WHEN ISNULL(A.AnalysisOutcome,'')='Submitted' THEN 'Submitted'
WHEN ISNULL(A.AnalysisOutcome,'')='Rejected' THEN 'Rejected'
WHEN (ISNULL(A.AnalysisOutcome,'')='Internal Processing Failure'
OR ISNULL(A.AnalysisOutcome,'')='Requirement Not Parsable')
THEN 'Analysis failure'
END as AnalysisOutcome,
US.AssignedTo,
ISNULL(AD.RequirementAnalysisId,'')RequirementAnalysisId,
AD.VagueWord,
AD.ContentText,
AD.Explanation,
AD.Suggestion,
AD.SuggestionList,
US.Title Summary2,
AD.VaguePhrase,
AD.VagueTypeText
,AD.VagueWord VagueWord2
,US.ModifiedOn
FROM (RequirementAnalysis A
RIGHT JOIN UserStory US ON
A.RequirementId=US.MyWizardUserStoryId)
left JOIN
AmbiguityAnalysisResult AD ON
A.RequirementAnalysisId=AD.RequirementAnalysisId
AND
A.RequirementAnalysisId=(SELECT MAX(RequirementAnalysisId) FROM RequirementAnalysis WHERE RequirementId=A.RequirementId
AND ProjectId=A.ProjectId)
)
SELECT UserStoryId,
[Description],
Summary,
UserStoryID,
ProjectId,
AnalysisOutcome,
AssignedTo,
RequirementAnalysisId,
RequirementId,
(SELECT distinct VagueWord
FROM cte
WHERE UserStoryId = c.UserStoryId
FOR XML PATH('VagueWordsArray'),TYPE)
,
(SELECT ContentText,Explanation,Suggestion,
SuggestionList,
Summary,VaguePhrase,VagueTypeText,VagueWord
FROM cte
WHERE UserStoryId = c.UserStoryId
FOR XML PATH('SuggestionData'),TYPE)
FROM cte c
WHERE UserStoryId in (141204,1400235)
GROUP BY UserStoryId,
[Description],
Summary,
UserStoryID,
ProjectId,
AnalysisOutcome,
AssignedTo,
RequirementAnalysisId,
RequirementId
FOR XML PATH('StoryData'),ROOT('xml'),TYPE
FOR JSON
쿼리로 같은 변환을 시도,하지만 난이 오류 :
메시지 13605, 수준 16, 상태 1, 줄 1
FOR JSON 절을 사용하여 이름이나 별명이없는 열 표현식과 데이터 소스를 JSON 텍스트로 포맷 할 수 없습니다. 명명되지 않은 열이나 테이블에 별칭을 추가합니다.
내가 JSON에 대한 쿼리 아래 시도 :
;WITH cte AS(
SELECT
US.Description
,US.Title Summary
,ISNULL(US.MyWizardUserStoryId,'')UserStoryID
,A.RequirementId,ISNULL(US.ProjectId,'')ProjectId,
--(case when A.AnalysisOutcome='Found' then 'Ambiguous' else 'Non Ambiguous' end)
CASE WHEN ISNULL(A.AnalysisOutcome,'')='' THEN 'Analysis Pending'
WHEN ISNULL(A.AnalysisOutcome,'')='Found' THEN 'Ambiguities found'
WHEN ISNULL(A.AnalysisOutcome,'')='Not Found' THEN 'No Ambiguities'
WHEN ISNULL(A.AnalysisOutcome,'')='Submitted' THEN 'Submitted'
WHEN ISNULL(A.AnalysisOutcome,'')='Rejected' THEN 'Rejected'
WHEN (ISNULL(A.AnalysisOutcome,'')='Internal Processing Failure'
OR ISNULL(A.AnalysisOutcome,'')='Requirement Not Parsable')
THEN 'Analysis failure'
END as AnalysisOutcome,
US.AssignedTo,
ISNULL(AD.RequirementAnalysisId,'')RequirementAnalysisId,
AD.VagueWord,
AD.ContentText,
AD.Explanation,
AD.Suggestion,
AD.SuggestionList,
AD.VaguePhrase,
AD.VagueTypeText
,US.ModifiedOn
FROM (RequirementAnalysis A
RIGHT JOIN UserStory US ON
A.RequirementId=US.MyWizardUserStoryId)
left JOIN
AmbiguityAnalysisResult AD ON
A.RequirementAnalysisId=AD.RequirementAnalysisId
AND
A.RequirementAnalysisId=(SELECT MAX(RequirementAnalysisId) FROM RequirementAnalysis WHERE RequirementId=A.RequirementId
AND ProjectId=A.ProjectId)
)
SELECT UserStoryId,
[Description],
Summary,
UserStoryID,
ProjectId,
AnalysisOutcome,
AssignedTo,
RequirementAnalysisId,
RequirementId
,
(SELECT distinct VagueWord
FROM cte
WHERE UserStoryId = c.UserStoryId
FOR Json PATH,ROOT('VagueWordsArray'))
,
(SELECT ContentText,Explanation,Suggestion,
SuggestionList,
Summary,VaguePhrase,VagueTypeText,VagueWord
FROM cte
WHERE UserStoryId = c.UserStoryId
FOR Json PATH,ROOT('SuggestionData'))
FROM cte c
WHERE UserStoryId in (141204,1400235)
GROUP BY UserStoryId,
[Description],
Summary,
UserStoryID,
ProjectId,
AnalysisOutcome,
AssignedTo,
RequirementAnalysisId,
RequirementId
FOR Json PATH,ROOT('StoryData')
우선 JSON은 MSSQL 2016 이상에서만 작동합니다. 두 번째로 표시되는 모든 열에 대해 별칭이 있는지 확인하십시오. – ShaiEitan