> SELECT CONCAT('Applicant's Name: ',AppID, CHAR(13) + CHAR(10)+'Application Date: ',AppDate,
> CHAR(13) + CHAR(10)+'The products are: ',@Products) AS Body
> FROM tblApplication
> WHERE Appno=@Appno
Products is not a member of tblApplictions but should be a list returned from the following:
> DECLARE @Products AS NVARCHAR(1000)
SELECT @Products = ProductDescr
> FROM tblProducts INNER JOIN tblApplication
ON tblProducts.AppID=tblApplication.AppID
> WHERE Appno=@Appno
The problem is I only get one record of products. Any kind of help would be appreciated.
please provide sample table definition and sample data.It would be good if you can create table variable and insert script for that and post the same here.
SELECT CONCAT('Applicant''s Name: ', ta.AppID, CHAR(13) + CHAR(10) + 'Application Date: ',AppDate,
CHAR(13) + CHAR(10)+'The products are: ', stuff( (SELECT ','+ ProductDescr
FROM #tblProducts tp
WHERE ta.AppId = tp.AppId
ORDER BY ProductDescr
FOR XML PATH(''), TYPE).value('.', 'varchar(max)')
,1,1,'')) AS Body
FROM #tblApplication ta
WHERE Appno=@Appno