1.将多笔记录转成一行,并用分隔符隔开
DECLARE @return_string NVARCHAR(4000)
BEGIN
SET @return_string = ''
select @return_string=@return_string + ';' + RTRIM(isnull( a.pl_name ,''))
from gi_product_line a, mbom_user_productline b
where a.pl_id = b.giis_pl_id
and a.Active = 1
and b.user_emp_no = @emp_no
ORDER BY a.pl_name
END
IF LEN(@return_string) > 0
SET @return_string = SUBSTRING(@return_string,2,LEN(@return_string) -1 )
PRINT @return_string