我有樣本值的XML列如何讓使用XPath和XQuery在SQL Server
<error>
<errorno>BL04002055</errorno>
<description>Smart Rule PROJECT_COUNTRYCODE_VAL Violated</description>
<description2>Country Code is required</description2>
<correction />
</error>
<error>
<errorno>BL01001973</errorno>
<description />
<description2>Error While Saving the Project info</description2>
<correction />
</error>
<error>
<errorno>Unable to Create Custom Object</errorno>
<description />
<description2>Smart Rule PROJECT_COUNTRYCODE_VAL Violated: Country Code is required
Error While Saving the Project info</description2>
<correction />
</error>
我想選擇逗號分隔
select *
--, Response.value(''/error/description2/text()'', 'varchar(8000)') as parsedString
, Response.query('/error/description2/text()') as parsedString
from #temp
兩個問題的內容描述值逗號分隔的XML值這裏。
- 我無法在上面的查詢中運行值函數。
- 使用查詢,我得到值連接,沒有空格或逗號。所以我需要在連接值上添加一些空格或逗號。