I\'ve written this query with the help of google to create a delimited list from a table but I didn\'t understand anything from this query.
Can anyone explain me wha
Take it apart step by step - from the inside out.
Step 1:
Run the innermost query and see what it produces:
SELECT E2.ename AS 'data()'
FROM emp AS e2
WHERE e2.DEPTNO = 10
FOR XML PATH('')
You should get an output something like:
CLARK KING MILLER
Step 2:
The REPLACE
just replaces spaces with ,
- thus turning your output into
CLARK, KING, MILLER
Step 3:
The outer query gets the deptno
value - plus the results from the inner query - and produces your final result.