February 6, 2012 at 6:30 am
Hi Mates,
I have a query which produces result set containing 2 or more rows as follows:
Query:
SELECT [BudgetCode] FROM [BudgetCode], [Employee] WHERE Employee.EmployeeId = [BudgetCode].[EmpId] AND [Employee].[EmployeeCode] = 'M-1-490'
Resultset:
BudgetCode
LM12340
LM13748
I wish to present result set as
BudgetCode
LM12340/LM13748
Can anyone help it out?
February 6, 2012 at 6:36 am
SELECT STUFF(CAST((SELECT '/' + [BudgetCode]
FROM [BudgetCode], [Employee]
WHERE Employee.EmployeeId = [BudgetCode].[EmpId] AND [Employee].[EmployeeCode] = 'M-1-490'
FOR XML PATH(''),TYPE) AS VARCHAR(MAX)),1,1,'') AS [BudgetCode]
February 6, 2012 at 7:05 am
Thankyou Cadavre 🙂 It worked!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply