【发布时间】:2021-08-30 16:24:06
【问题描述】:
我有一张这样的桌子:
| ID | C1 | C2 | seq |
|---|---|---|---|
| 1 | This is my re | ally long sentence | 1 |
| 1 | This is my re | stored in a | 2 |
| 1 | This is my re | really terrible format | 3 |
我需要一些 SQL 查询或存储过程将其拉出,使其显示为“这是我的非常长的句子,以非常糟糕的格式存储”
select
case
when seq = '1'
then c1 else ''
end + stuff((select c2 from table t2
where t2. id = t1.id and t2.seq = t1.seq
for xml path('')), 1, 1, '')
from
table t1
我已经完成了,但它正在将 XML 放入其中,我不知道为什么。任何帮助表示赞赏。
【问题讨论】:
-
什么版本的 SQL Server?
标签: sql-server tsql stuff