MS SQL tutorial on FOR XML and concatenation and STUFF function

preview_player
Показать описание
This is a Miscrofot SQL tutorial video demonstrating the use of the FOR XML clause. This video shows how FOR XML can be used to create a comma delimited list and how this list can be joined to other tables to create more meaningful data. This solution includes the use of the STUFF function

Complimentary SQL:
select de.Name, stuff((
select ',', em.NationalIDNumber as [text()]
from HumanResources.Employee em
inner join HumanResources.EmployeeDepartmentHistory eh on em.BusinessEntityID = eh.BusinessEntityID and eh.EndDate is null
where eh.DepartmentID = de.DepartmentID
for xml path('')
), 1, 1, '')
from HumanResources.Department de
order by de.Name
Комментарии
Автор

Oh my goodness, this is extremely helpful!! Thank you for this, this helped me with my project for my apprenticeship! You explain things carefully, really good! 💗

Faerielzzy
visit shbcf.ru