Here we go, to convert a column into row or string separated by a delimiter, we can use coalesce. Just create below function and call it for your SP. Avoid where condition and parameter if not required.
create FUNCTION ConvertColumnToRow (@id int)
RETURNS varchar(100)
AS
BEGIN
DECLARE @List varchar(100)
SELECT @List = COALESCE(@List + ', ', '') + CAST(Name AS varchar(10))
FROM Employee
WHERE ID = @id
RETURN(@list)
END;
go
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment