filmov
tv
MS SQL tutorial on FOR XML and concatenation and STUFF function

Показать описание
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
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
Комментарии