March 8, 2005 at 11:46 am
I need to make a large amount of data edits to a database. I have an application that assigns a unique code to users. I do a SELECT statement to pull out the user codes that I need to change. Based on the results of that SELECT Statement,I need to compare the user codes and UPDATE 8 other tables.
March 8, 2005 at 12:23 pm
Since your codes are unique, you should be able to do a loop.
Delcare the variables @CurrentID, @MaxID, @NewID
SELECT @CurrentID = (SELECT MIN( ID) FROM Table)
SELECT @MaxID = (SELECT MAX( ID) FROM Table)
WHIILE @CurrentID <= @MaxID
BEGIN
MAKE YOUR @NewID EQUAL WHATEVER CHANGES YOU WANT TO YOUR @CurrentID (the unique code you refered to).
Do your table manipulations here using the @CurrentID to match records...
SELECT @CurrentID = (SELECT MIN( ID) FROM Table WHERE ID > @CurrentID)
END
I wasn't born stupid - I had to study.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy