これはもう1つの「for XML」質問ですが、明示的モードなしでこれを実行できるかどうかはわかりません。それができなければ、私はただそれと一緒に暮らさなければならない。SQL Server 'FOR XML'が「行」要素ノードに値を取得する
次は、現在、私のselect文です:
SELECT
[stream_id] as '@stream_id',
[path_locator] as '@path_locator',
[parent_path_locator] as '@parent_path_locatr',
[file_type] as '@file_type',
[cached_file_size] as '@cached_file_size',
[creation_time] as '@creation_time',
[last_write_time] as '@last_write_time',
[last_access_time] as '@last_access_time',
[is_directory] as '@is_directory',
[is_offline] as '@is_offline',
[is_hidden] as '@is_hidden',
[is_readonly] as '@is_readonly',
[is_archive] as '@is_archive',
[is_system] as '@is_system',
[is_temporary] as '@is_temporary',
[name] as '/name',
dbo.udf_GetChildren(path_locator)
FROM @Merged
WHERE path_locator.GetLevel() = 1
FOR XML PATH'file'), ROOT('files'), TYPE
これは、次のXMLを出力します
<files>
<file stream_id="" etc...>
<name>NAME</name>
</file>
</files>
これは悪くないですが、私が本当に欲しいと、を取得することですファイル要素の値としての要素の値。これは、私が明示的なモードなしで行うことができると仮定しているような単純な作業ですが、私はそのようなことについてかなり間違っています。
私は '/'マーカーを使用しようとしましたが、これは私が望む効果がないようです(たとえばUpdate XML node (in an XML column) in SQL Server 2005 with another column value in the same row)。
編集: 希望XMLは、単純にこのようになります:助けを
<files>
<file stream_id="" etc...>NAME</file>
</files>
感謝します。
: –
@AdamWengerが完了しました。ありがとう。 – dansan
'name '' * ''を試しましたか? –