0

Below statements fails for ADS

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

Please help

Dileep Paul
  • 167
  • 3
  • 17

1 Answers1

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.
Mike Sherrill 'Cat Recall'
  • 91,602
  • 17
  • 122
  • 185