xpath を使用して名前空間を定義して XML フィールドから値を選択する方法は知っていますが、いくつかの xpath クエリを使用してそれらを選択項目に割り当てる必要があります。以下を実行するよりも簡単な方法はありますか?
SELECT
id, name,
[XML].value('declare namespace test="http://www.test.org/xml/";
declare namespace test2="http://www.test2.org";
(//test:Address[1][test2:Global=1]/test:Street)[1] ', 'varchar(max)') AS streetLocation1,
[XML].value('declare namespace test="http://www.test.org/xml/";
declare namespace test2="http://www.test2.org";
(//test:Address[2][test2:Global=1]/test:Street)[1] ', 'varchar(max)') AS streetLocation2
FROM
TEST
交換したい
'declare namespace test="http://www.test.org/xml/";
declare namespace test2="http://www.test2.org";'
変数を使用して。文字列を追加しようとしましたが、次のようになりました。
XML データ型メソッド「値」の引数 1 は、文字列リテラルでなければなりません。
もっと簡単な方法があるはずです。
ありがとう、
-ジェームズ