我有以下查询:
SELECT s FROM dbo.Split(',',(
select
emp.Data
FROM Employee emp
WHERE EmployeeID = 56640
))
“数据”列是逗号分隔值:
emp.Data has the value: '461086,461104'
返回下表:
现在,我需要添加到此选择EmployeeID
列,所以我需要这样的东西
SELECT s FROM dbo.Split(',',(
select
emp.EmployeeId,
emp.Data
FROM Employee emp
WHERE EmployeeID = 56640
))
但这给了我一个错误。
有任何线索吗?
答案 0 :(得分:0)
您正在寻找cross apply
:
select emp.EmployeeId, s.val
FROM Employee emp CROSS APPLY
dbo.split(',', emp.data) s(val)
WHERE emp.EmployeeID = 56640;