If you ever google sql for loop, just stop right there.
SQL is by definition a for loop.
A SELECT statement does nothing more than iterate over the rows in the database that satisfy the conditions of the query.
Therefore, if you want a for loop that sets a variable and then does some operation on one row at a time, JUST STOP. What you really want is a join somehow, and you can get it all done much simpler in terms of code and processing power. It will be easier to debug and to understand, and you won't have to worry about setting up the attendant variables to process a true for loop. SQL is a for loop, use it that way!
Popular Posts
-
Tonight I attended a conference hosted by The Church of Jesus Christ of Latter-day Saints. It's topic was the protection of the institu...
-
Rules of Coding The most important language you will ever code in: English (or the common spoken language used in your company). -- So...
-
Excel likes to write numbers into scientific notation. This raises a problem if you are trying to message data into a database from an exce...
-
Dear Heavenly father, thank you for the impressions though hast given me this day. I am grateful for Jesus Christ who died for me. Not the...
-
Adam, Adam, thou art perfect before me. Thou shalt not lose thy children nor shalt thou see the bars of prison, jail, or cell ever again. ...
-
You can use an XML string to pass any number of options to a SQL stored procedure like so Use a scalar valued function to get one value a...
-
Here is how to parse a date that is in the format of mm/dd/yyyy: // Parse string with date but no time component. string dateStr...
-
Last night I thought about how stable God is. He plants his promises in our hearts and watches them grow. As men, we foolishly think that ...
-
This blog is to let you know how to use the SQL import wizard. It is very interesting. The most important thing to remember is that you ca...
-
I believe there is one good way to help this countries citizens, as well as people all over the world, buy homes and keep them. The best sy...