Credit goes to Echoes. I modified to code so that now its returning value to the table variable and displaying two columns employee id and the related orderid separated by commas.
Thanks once again echoes.
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
Alter function [dbo].fn_inonerow(@p_empid int)
Returns @v_table table(employeeid int,orderid nvarchar(4000))
As
Begin
Declare @orderids nvarchar(4000)
Select @orderids=coalesce(@orderids + ',','') + rtrim(orderid)
From orders a
inner join employees b
on b.employeeid=a.employeeid
where b.employeeid=@p_empid
Insert into @v_table(employeeid,orderid)
Select Distinct a.employeeid, @orderids
From orders a
inner join employees b
on b.employeeid=a.employeeid
Where b.employeeid=@p_empid
Return
End
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
--Select * from [dbo].fn_inonerow(3)