Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What's the equivalent of VFP's Scan...Endscan in SQL?
Message
De
18/04/2007 06:46:10
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01217180
Message ID:
01217224
Vues:
33
DECLARE @MinTablePK AS int -- or the type of PK field you use for that table
DECLARE @cCode varchar(200)
SELECT @MinTablePK = MIN(PKField) FROM MyTable
WHILE @MinTablePK IS NOT NULL
      BEGIN
          SELECT @cCode = Code FROM MyTable WHERE PKField = @MinTablePK
          UPDATE MyTable2 SET ... WHERE  Code = @cCode
          DELETE FROM MyTable2 WHERE  Code = @cCode
          SELECT @MinTablePK = MIN(PKField) FROM MyTable WHERE PKField > @MinTablePK
      END
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform