0

以下语句对于 ADS 失败

DECLARE @listStr VARCHAR(MAX)
SELECT @listStr = COALESCE(@listStr+',' ,'') + Name FROM Product
SELECT @listStr

请帮忙

4

1 回答 1

1

In general, the preferred way to do this is to use whatever function the dbms provides. MySQL has group_concat(), PostgreSQL has array_agg(), Oracle has listagg(), etc. But Advantage Server doesn't seem to support any functions like these.

The next best way is to build a user-defined function. Advantage supports user-defined functions. Here's one implementation; I haven't tested it.

Other ways, which might or might not be possible, are

  • extending the dbms by writing custom functions in a low-level language, often C or C++, and
  • doing the concatenation in application code instead of on the server.
于 2013-08-05T15:21:19.353 回答