Posts Tagged ‘cursor’
SQL CURSOR Performance – SQL For Programmers
Last week I showed how to use the SQL CURSOR to loop through records in a database. In that article I mentioned that you want to avoid using the CURSOR if you can because it has performance problems.
The article was posted on DZone where a self-proclaimed SQL guru picked it up and left a comment basically stating an alternate way of looping through records that would do the same thing but didn’t require the CURSOR. What he suggested was the common practice of doing something like this:
Other Related Items:
Norpro Stainless Steel Vertical Poultry RoasterNorpro's vertical poultry roaster is designed to allow fats to drip off your chicken or other poultry as it cooks, leaving only juicy, flavorful, lowe... Read More >
Cuisinart Supreme Grind Automatic Burr Mill (CCM-16PC1)A stylish grinder for the serious coffee buff, this Cuisinart Supreme Grind automatic burr mill provides plenty of options and good results in an attr... Read More >
SQL CURSOR – SQL For Programmers
One of the things it took me a while to figure out was how to get a stored procedure to loop through data in a table and pull out specific data I needed.
There are actually two parts to this question. First, you should always try to find some other way of doing whatever it is you think you need to do by processing one row at a time. SQL is a “Set-Based” language and as such it expects you to work with the whole set. That’s what it was designed to do best and that’s why it has functions such as MAX, MIN, SUM, AVG, etc. Many of these functions in combination with a good WHERE clause will get you the information you need.
However, there are times when you’ll need to process the information one record at a time, and this is what the CURSOR was created for.
Other Related Items:
Beginner's SQL Server 2000 T-SQL Programming on DVDLearn SQL Server 2000/TSQL Programming as you watch DVDs on your TV or laptop DVD player. This 2-disc set contains 7 lessons that provide you a revi... Read More >
Smurf Characters Shuffle Lounge Pants for menThese lounge pants feature Belgian artist Peyo's copyright Smurf character faces in an all-over print on a navy background. Machine washable with button fly and covered elastic waistband with drawstring tie.
Londons Times Funny Dogs Cartoons - Dog Not Playing Fetch - Light Switch Covers - double toggle switchDog Not Playing Fetch Light Switch Cover is new and handcrafted utilizing unique process resulting in a stunning high gloss ceramic-like finish. SET OF MATCHING SCREWS IS INCLUDED giving it a perfect finishing touch. Made of durable metal material.

