Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scan of table
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01312331
Message ID:
01312865
Vues:
18
Boris,

Your WHILE loop never ends because @MasterRef will never be NULL. IOW, when query that assigns local variables retuns 0 records, the variables remains unchanged not set to NULL

>
>Sorry for late answer, but was too busy to do anything but read.
>Why you use two tables when you need just one?
>You could get both fields from ClaimRef table, isn't it?
>
>Create Procedure DontUseCursors
>As
>DECLARE @MasterRef    varchar(10)
>DECLARE @MasterRefMax varchar(10)
>DECLARE @ClaimRef     varchar(10)
>
>
>Declare @i int
>
>SELECT @MasterRef    = c.MasterRef,
>       @MasterRefMax = Tbl1.MaxRef,
>       @ClaimRef     = c.ClaimRef
> FROM claim c
>      INNER JOIN (SELECT MIN(ClaimRef) AS ClaimRef, MAX(ClaimRef) AS MaxRef FROM Claim) Tbl1
>ON c.ClaimRef = Tbl1.ClaimRef
>
>WHILE @MasterRef IS NOT NULL AND @MasterRef <= @MasterRefMax
>    BEGIN
>       print @ClaimRef
>       SELECT @MasterRef = c.MasterRef,
>              @ClaimRef  = c.ClaimRef
> 	FROM claim c
>        INNER JOIN (SELECT MIN(ClaimRef) As ClaimRef FROM claim
>                           Where ClaimRef > @ClaimRef) Tbl1
>	ON p.ClaimRef = Tbl1.ClaimRef
>    END
>
>again not tested :-)
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform