Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's the equivalent of VFP's Scan...Endscan in SQL?
Message
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
01217180
Message ID:
01217224
Views:
32
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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform