I'll try to explain it.
First, I'll create some sample data to follow along and keep it short.
CREATE TABLE #SampleData(
Criteria_Numberint,
Criteria_Namevarchar(50),
Calc_Pointsint,
Max_Pointsint);
INSERT #SampleData
SELECT 1, 'Criteria A', 5, 10 UNION ALL
SELECT 1, 'Criteria B', 13, 20 UNION ALL
SELECT 1, 'Criteria C', 70, 100;
If we run the following query using FOR XML PATH ('') and assign an alias to the column, we'll end up with the tags <Value></Value> for each row of our table.
SELECT bidPoints = (
SELECT Value = LTRIM(RTRIM(CRITERIA_NAME)) + ' - '
+ CONVERT(varchar(10),Calc_Points ) + '/'
+ CONVERT(varchar(10),Max_points) + CHAR(13)
FROM #SampleData
ORDER BY CRITERIA_NUMBER
FOR XML PATH(''));
--Result
--<Value>Criteria A - 5/10& #x0D;</Value><Value>Criteria B - 13/20& #x0D;</Value><Value>Criteria C - 70/100& #x0D;</Value>
If we remove the alias from the column, the tags will be gone as well because SQL Server won't know what field is it as it is an unnamed column
SELECT bidPoints = (
SELECT LTRIM(RTRIM(CRITERIA_NAME)) + ' - '
+ CONVERT(varchar(10),Calc_Points ) + '/'
+ CONVERT(varchar(10),Max_points) + CHAR(13)
FROM #SampleData
ORDER BY CRITERIA_NUMBER
FOR XML PATH(''));
--Result
--Criteria A - 5/10& #x0D;Criteria B - 13/20& #x0D;Criteria C - 70/100& #x0D;
Note that we still have a code representing the CHAR(13) (I added a space to it in this post to be able to show it). To remove the XML codes as this one or the ones for <, >, & and others, we use the TYPE and .value to avoid this characters being tokenized. Resulting on:
SELECT bidPoints = (
SELECT LTRIM(RTRIM(CRITERIA_NAME)) + ' - '
+ CONVERT(varchar(10),Calc_Points ) + '/'
+ CONVERT(varchar(10),Max_points) + CHAR(13)
FROM #SampleData
ORDER BY CRITERIA_NUMBER
FOR XML PATH(''), TYPE).value('.','nvarchar(4000)');
--Result
--Criteria A - 5/10
--Criteria B - 13/20
--Criteria C - 70/100
--
To avoid the final CHAR(13) we can change the order of the elements in our string concatenation and use STUFF to remove the first character.
SELECT bidPoints = STUFF((
SELECT CHAR(13) + LTRIM(RTRIM(CRITERIA_NAME)) + ' - '
+ CONVERT(varchar(10),Calc_Points ) + '/'
+ CONVERT(varchar(10),Max_points)
FROM #SampleData
ORDER BY CRITERIA_NUMBER
FOR XML PATH(''), TYPE).value('.','nvarchar(4000)'), 1, 1, '');
I hope that this becomes easier to understand.