我有一个存储过程。我只是想将许多行值连接成单个字符串。此外,最终结果需要返回具有某一列的一行,以将所有行值串联为字符串。我尝试了下面的代码。但它抛出一个错误。请帮我找出问题所在。
代码
ALTER PROCEDURE [dbo].[Usp_getjobdetails] (@jobID INT,
@foos VARCHAR(max))
--,@l varchar(max),@ts varchar(max))
AS
BEGIN
--select @en as int
--select @l as l.Location
--select @ts as ts.TechnicalSkills
SELECT jobcode,
jobtitle,
experiences,
(SELECT @foos = COALESCE(@foos + ',', '')
+ e.educationname
FROM tbleducation
WHERE educationid = je.educationid) AS Edu,
l.location,--=COALESCE( @l + ', ', '') + l.Location,
ts.technicalskills,
--=COALESCE ( @ts + ', ', '' )+ ts.TechnicalSkills,
jobdescription
FROM tbljobs j
INNER JOIN tbljobs_education je
ON je.jobid = j.jobid
INNER JOIN tbljobs_locations jl
ON jl.jobid = j.jobid
INNER JOIN tbljobs_technicalskill jts
ON jts.jobid = j.jobid
INNER JOIN tbleducation e
ON e.educationid = je.educationid
INNER JOIN tbllocations l
ON l.locationid = jl.locationid
INNER JOIN tbltechnicalskills ts
ON ts.technicalskillid = jts.technicalskillid
WHERE j.jobid = @jobID
END
tbljobs tbl
JobCode JobTitle Experience Edu Location Description
PITCS41 JDev 12-14 BSC,BCA,MSC Delhi Asp.Net A highly
我需要类似上述结果的东西。