【问题标题】:SQL for XML Path: Can one table cell value for each row be used as tag name?SQL for XML Path: Can one table cell value for each row be used as tag name?
【发布时间】:2022-12-27 21:11:08
【问题描述】:

I have a quite complex query which should generate XML. Problem is, for each row of this query, one of the values from select should be used as tag name. For example if the row is like this:

columna | columnb | columnc
value11 | value12 | value13
value21 | value22 | value23

xml would contain something like this, for example:

<value11> value12 </value11>

so one table value is used as tag name.

Is that possible?

【问题讨论】:

    标签: sql sql-server xml tags


    【解决方案1】:

    We use the FOR XML PATH SQL Statement to concatenate multiple column data into a single row:

    .RAW .Auto .EXPLICIT .PATH

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-01
      • 2022-12-02
      • 2023-02-17
      • 2022-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多