从DB2中的查询创建分隔符的字符串 [英] Create a delimitted string from a query in DB2

查看:173
本文介绍了从DB2中的查询创建分隔符的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从iSeries(AS / 400)上的DB2中的查询结果创建一个分隔符的字符串。我在T-SQL中做到了这一点,但是在这里找不到办法。

I am trying to create a delimitted string from the results of a query in DB2 on the iSeries (AS/400). I've done this in T-SQL, but can't find a way to do it here.

这是T-SQL中的代码。我正在寻找DB2中的一个等价物。

Here is my code in T-SQL. I'm looking for an equivelant in DB2.

DECLARE @a VARCHAR(1000)
SELECT @a = COALESCE(@a + ', ' + [Description], [Description])
FROM AP.Checkbooks
SELECT @a

如果表中的说明如下所示:

If the descriptions in my table look like this:


Desc 1

描述2

描述3

Desc 1
Desc 2
Desc 3

然后它将返回:


Desc 1,Desc 2,Desc 3

Desc 1, Desc 2, Desc 3


推荐答案

我试图在OLEDB中做到这一点,从我理解你不能这样做,因为你不能在SQL中为OLEDB做任何事情,例如声明变量或创建一个表。所以我想没有办法。

I'm trying to do this in OLEDB and from what I understand you can't do this because you can't do anything fancy in SQL for OLEDB like declare variables or create a table. So I guess there is no way.

这篇关于从DB2中的查询创建分隔符的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆