• In fact, concatenating strings will not do on this example.

    This works when you have one scalar value to return, instead of a whole table.

    But there are workarounds, of course.

    I don't intend here to suggest you a "best-practice" approach, but simply something that can help you.

    For instance, try declaring a table variable (let's call it @tmpResult) with fields codName and PhoneNumbers.

    Then create a loop (using WHILE stement) over each record on dbo.tblUser.

    Within the loop, you run this SELECT statement you used to concatenate PhoneNumbers for each codUser.

    Finally you should populate (using INSERT statement) @tmpResult with each record (@vchName, @AllPhones)

    At the end, you show the records within the table variable (with a SELECT statement).

    I hope it can help.