Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2011-10-27 : 02:24:21
|
I created a function to get some information from a table and return it as a stringthe issue is it is now only returning 1 row - if there is more I want it to return all rows just separated by a -How would I change thisALTER function [dbo].[getplinfo]( @participantid int)returns nvarchar(450)asbegin declare @retval nvarchar(450) select @retval =nameoforganization + '-' + pc.city + '-' + isnull(convert(varchar, datebeganposition, 103),'')+ '-' + isnull(convert(varchar, dateendedposition, 103),'') from pl left join city pc on pc.id=pl.workcityid where pl.participantid=@participantid return @retvalendGOSET ANSI_NULLS OFFGOSET QUOTED_IDENTIFIER OFFGO |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-27 : 02:56:58
|
[code]ALTER function [dbo].[getplinfo](@participantid int)returns nvarchar(450)asbegindeclare @retval nvarchar(450)select @retval =coalesce(@retval,'') + nameoforganization + '-' + pc.city + '-' + isnull(convert(varchar, datebeganposition, 103),'')+ '-' + isnull(convert(varchar, dateendedposition, 103),'') from pl left join city pc on pc.id=pl.workcityid where pl.participantid=@participantidreturn @retvalendGOSET ANSI_NULLS OFFGOSET QUOTED_IDENTIFIER OFFGO[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|