これは別の「for xml」の質問ですが、明示モードなしでこれを実行できるかどうかはわかりません。それができないなら、我慢するしかない。
以下は、現在私の選択ステートメントです:
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>
これは悪くありませんが、 name要素の値をfile要素の値として取得したいのです。これは非常に単純なタスクであり、明示モードなしで実行できると思いますが、そのようなことについてかなり頻繁に間違っています。
「/」マーカーを使用してみましたが、これは必要な効果がないようです (たとえば、SQL Server 2005 の XML ノード (XML 列内) を同じ行の別の列値で更新)。
編集: 必要な xml は次のようになります。
<files>
<file stream_id="" etc...>NAME</file>
</files>
助けてくれてありがとう。