プロパティ情報を返すAPIを使用しています。一部のテキスト情報は子ノード間で保存され、単一の文字列(VARCHAR)に連結したいと思います。
私のプロセスでは、Webサービスを介してxmlを取得し、これをprocに渡して、xml値を抽出し、ビューに挿入します。これは、返されるxmlのスニペットです。
<properties>
<property propertyid="1234">
<bullets>
<bullet>nice garden</bullet>
<bullet>it smells a bit</bullet>
<bullet>body under the patio</bullet>
</bullets>
</property>
...
</properties>
これは、xmlがどのようにクエリされて値を抽出するかを垣間見ることができます。
INSERT
INTO VProperty
( PropertyId,
Description
)
SELECT P.value('@propertyid', 'INT'),
NULL -- extract all the bullet text values into a single string
FROM @xml.nodes('/properties/property')
この例では、xmlから情報を抽出できるようにしたいので、最終的には次のようになります。
PropertyId Description
1234 'nice garden\r\nit smells a bit\r\nbody under the patio
これは純粋なsql/xmlで可能になるのでしょうか、それともSQLランドに入る前にxmlで前処理を実行する必要があるのでしょうか。
(いつものように)どんな助けでも大歓迎です。