Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Debugging a WHILE EXISTS
Message
De
02/11/2008 14:18:45
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01358902
Message ID:
01359015
Vues:
29
>
>DECLARE @lcField Char(40)
>DECLARE @lcField2 Char(40)
>DECLARE @lnNumero Integer
>DECLARE @lnNumero2 Integer
>
>WHILE EXISTS (SELECT 1 FROM Relation)
>BEGIN
>   SELECT @lnNumero=Numero,@lcField=Field,@lcField2=Field2 FROM Relation
>   PRINT 'Update Relation '+@lnNumero+'.'
>
>   SELECT @lnNumero2=Numero FROM Field WHERE Field=@lcField
>
>   UPDATE Relation SET NoField=@lnNumero2 WHERE Numero=@lnNumero
>
>   SELECT @lnNumero2=Numero FROM Field WHERE Field=@lcField2
>
>   UPDATE Relation SET NoField2=@lnNumero2 WHERE Numero=@lnNumero
>
>END
>
I need to select all records at first and loop. I do not think this would do it.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform