Click to See Complete Forum and Search --> : Comma-delimited Output


nkagi
June 10th, 2009, 10:35 AM
Hi All,

I have attached two documents that I need help with. The one is the script that I have written to access data and the other is the view structure that i want to access data from. The problem is that I'm working is SQL2000 and I want to print a card for the street trader. The street trader is selling more than one product, when I try to print the card for one trader it prints as many cards as the products that he's selling. What can I do, to make sure that it prints only one card.

hspc
June 10th, 2009, 01:17 PM
The attachments don't explain everything, (what is the [dbo].[findstandbyidno] table?)
Anyway, why is (WHERE [rent] = @rentID) commented?

ComITSolutions
June 12th, 2009, 04:22 AM
Alter your function dbo.[ufn_Getdescription] as below




CREATE FUNCTION [dbo].[ufn_Getdescription] ( @rentID INT )
RETURNS VARCHAR(8000)
AS
BEGIN

DECLARE @Descriptions VARCHAR(8000)
Declare @Desc Valrchar(50)

Declare TmpCur For select [Description] From findstandbyidno where rent = @rentID
Open TmpCur
Fetch Next from TmpCur Into @Desc
Begin
if @desc is not null
set @Descriptions=@Descriptions + Case when @Descriptions='' then '' else ',' end + @Desc
Fetch Next from TmpCur Into @Desc
End
close tmpcur
Deallocate tmpcur
RETURN @Descriptions
END