Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Thanks for replyin Peso..but still getting same results..i have one function:CREATE FUNCTION [dbo].[UDFNumberList](@FK varchar(200))RETURNS varchar(5000) ASBEGINDECLARE @Number varchar(8000)SELECT @Number= COALESCE(@Number+',','') + convert(varchar(200),m.media_id)FROM dbo.media minner join contact_media cmon cm.media_id = m.media_idinner join contact con c.contact_id = cm.contact_idWHERE c.contact_id=@FKRETURN @NumberENDin media_id the values are 9,15,28,26,7,1,0 - integer values..but i am getting wrong results...can anyone help me.thanks
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts
Posted - 2009-03-03 : 09:29:07
I suggest you format your post. This will give anyone a headache.
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2009-03-03 : 09:29:41
One JOIN less
CREATE FUNCTION [dbo].[UDFNumberListnumber1]( @FK varchar(200))RETURNS VARCHAR(5000) ASBEGIN DECLARE @Number varchar(8000) SELECT @Number = COALESCE(@Number + ',', '') + convert(varchar(200), cm.media_id) FROM contact_media AS cm inner join contact c on c.contact_id = cm.contact_id WHERE c.contact_id = @FK RETURN @NumberEND