This is my data:
Im trying the following code:
SELECT *, STRING_AGG(SUBTIPO_PRODUCTO, ' | ') WITHIN GROUP (ORDER BY ORDEN_PRODUCTOS) PRODUCTOS FROM #ORDEN_PRODUCTOS and I'm getting the following error:
'STRING_AGG' is not a recognized built-in function name.
Is string_agg locked for SMSS 17? Is the code wrong?

SELECT @@VERSIONin SSMS and tell us what version it says you are using.STRING_AGGis only available in SQL Server 2017 or newer - not in 2016..... and it only depends on the server (engine) version - not the SSMS version you're using .