Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to derive the result set using SQL Statement
Message
 
 
À
30/06/2004 05:57:54
Rene Lovino
Bigfoot Global Solutions, Inc
Cebu, Philippines
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00918903
Message ID:
00919470
Vues:
21
This message has been marked as the solution to the initial question of the thread.
Hi Rene,

I'm not sure if it'll be faster but you can do it with Query+UDF.
SELECT DISTINCT transfer, dbo.ufn_binlist(transfer)
	FROM mytable1

-- UDF ufn_binlist
CREATE FUNCTION ufn_binlist 
	(@transfer char(10))
RETURNS varchar(1024)
AS
BEGIN
DECLARE @str varchar(1024)

SELECT @str = ISNULL(@str + ', ', '') + bin
	FROM mytable1
	WHERE transfer = @transfer
RETURN @str
END
>
>I have the following sample data:
>Transfer # Item #               Bin
>---------- -------------------- ----------
>1000000018 AEROCHAIR-A1         MASTER
>1000000019 BRACKET              MASTER
>1000000020 BRACKET              MASTER
>1000000021 BRACKET              MASTER
>1000000022 BRACKET              DEFECTIVE
>1000000022 BRACKET              MASTER
>1000000023 AEROCHAIR-A1         DEFECTIVE
>1000000023 AEROCHAIR-A1         MASTER
>1000000024 AEROCHAIR-A1         MASTER
>1000000024 AEROCHAIR-A1         DEFECTIVE
>1000000024 AEROCHAIR-A1         RECEIVING
>
>I want to derived a result such as follows without using cursor:
>I have already derived the said result set using cursor (declare cursor) but the result of my query seem a litle bit slow.
>Transfer # Item #               Bin
>---------- -------------------- ----------
>1000000018 AEROCHAIR-A1         MASTER
>1000000019 BRACKET              MASTER
>1000000020 BRACKET              MASTER
>1000000021 BRACKET              MASTER
>1000000022 BRACKET              DEFECTIVE, MASTER
>1000000023 AEROCHAIR-A1         DEFECTIVE, MASTER
>1000000024 AEROCHAIR-A1         DEFECTIVE, MASTER, RECEIVING
>Note that the result set was group bu Transfer # + Item # and the Bin value should be comma delimeted for Transfer # and Item # that occurs several times. The possible value of the bin field depends on many entries in the said table.
>
>Is anybody there have an idea of deriving the said result set using other alternative without using cursor?
>
>
>TIA,
>
>Rene
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform