I want to join a column that has multiple values, and join them as comma separated list values into a single field. The SQL query works, however I think I run into performance issues.
After 30 minutes of loading my SQL code it gives timeout problems: DataSource.Error: Microsoft SQL: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Whenever I select top 1000 rows, it still loads for an entire minute.
The LEDGERTRANS.TXT is a string, and also with MAX() surrounding it, it gives me a timeout.
MRPRJPROJTRANSPOSTING has 2,5M rows LEDGERTRANS +/- 5M rows, though I only join what I need from it.
The following code is what I use:
SELECT
MRPRJPROJTRANSPOSTING.VOUCHER,
[Factuuromschrijving(en)] = STUFF(
(SELECT ',' + LEDGERTRANS.TXT
FROM LEDGERTRANS
WHERE LEDGERTRANS.VOUCHER = MRPRJPROJTRANSPOSTING.VOUCHER
AND LEDGERTRANS.DATAAREAID = MRPRJPROJTRANSPOSTING.DATAAREAID FOR
XML PATH (''))
, 1, 1, '' )
FROM MRPRJPROJTRANSPOSTING
Is there maybe another way to make a similar join?
Kind regards, Igor