SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Function Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tooba
Posting Yak Master

195 Posts

Posted - 02/19/2013 :  23:03:23  Show Profile  Reply with Quote
Hi Guys,

Here is my UDF

Create Function [dbo].[udf_GetValue](@PID int)


returns varchar(1000)
as

begin
Declare @Message varchar(1000)

Select @Message = Message
From tbMessage
Where PId = @PID


return isnull(@Message,'')


end

I want to know
Let say if there is two PID How i can get , seperate Messages
End Result should be

MESSAGE
MSG1,MSG2,MSG3,....

I know UDF return only one value.
ANy advise?

bandi
Flowing Fount of Yak Knowledge

India
2223 Posts

Posted - 02/19/2013 :  23:44:57  Show Profile  Reply with Quote
begin
Declare @Message varchar(1000)

   Select @Message = COALESCE(@message, ', ') + Message + ', '
   From tbMessage
   Where PId = @PID
   
   return STUFF(isnull(@Message,''), 1,2,'')
end

SELECT dbo.udf_GetValue( IdValue)


--
Chandu
Go to Top of Page

tooba
Posting Yak Master

195 Posts

Posted - 02/20/2013 :  00:46:02  Show Profile  Reply with Quote
Awesome Bandi, Thank you for your help....
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2223 Posts

Posted - 02/20/2013 :  00:49:25  Show Profile  Reply with Quote
quote:
Originally posted by tooba

Awesome Bandi, Thank you for your help....


Welcome

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000