Friday, September 16, 2011

While Loop : An SQL Server 2005 alternative for cursors

While Loop in SQL Server

SQL Server 2005 alternative for cursors is While loop. SQL Server 2005 provides a while loop which we can use to iterate through any table having at least one column. The column must have unique value (primary key is generally prefered). A sample code is provided below which is MSSQL Server Specific code and is at least 5 times faster than cursor.
Declare @PresentIDint;
Set @PresentID = (Select min(column_name) from your_table );
/*Starts the iterrational loop*/
While @PresentID is not null
/*Code segment where you have access to @PresentID*/
/*Next line required to keep iterating*/
Set @PresentID = (Select min(column_name) from your_table where column_name > @PresentID);

Relevant AD
This ad may be helpful, if relevant to your search.


Cursor is an SQL Server 2000 feature similar to the iteration loop available in the several programming languages.  The nearest match for Cursor is While loop and For Loop in the programming languages. Cursor should be avoided as much as possible.
[Did you like this post ? Do leave a comment or share with your Facebook friends. This will give me more reasons to write such posts.]


  1. toms outlet,
    nike roshe,
    prada handbags,
    soccer jerseys,
    michael kors outlet store,
    true religion jeans,
    oakley sunglasses,
    nike free 5,
    louis vuitton bags,
    chanel handbags,
    chanel handbags,
    louis vuitton handbags,
    louis vuitton outlet,
    ghd hair straighteners,
    nba jerseys,
    coach outlet,
    true religion jeans,
    swarovski crystal,
    mbt shoes,
    michael kors handbags,
    chanel handbags,
    michael kors outlet online,
    polo ralph lauren,
    the north face clearance,
    jordan shoes,
    beats by dr dre,
    the north face uk,

  2. Kendall Jenner’s the model of the moment. Having walked for the likes of Chanel, Dolce and Gabbana, Fendi, Marc Jacobs and Givenchy she is racking up a cheap ray ban sunglasses sale under 30$ serious CV. Victoria Beckham is said to have earmarked her for her next catwalk show. Having met with her recently the designer is cheap ray bans said to have called her the most naturally beautiful model.All that catwalk dressing is giving her some great styling sense. At Geoffrey’s in ray ban outlet Malibu she’s out celebrating her dad’s birthday with sister Kylie and half sisters Kim, Khloe and Kourtney. Like many a model that has Ray Ban Sunglassses Sale access to top designer sunglasses from the big fashion houses Ray-Ban is still a go-to. She coordinates her look with the Ray-Ban 3025 cheap ray bans for sale Aviator with gold frame and blue lens. The gold frame is synced up with her sandals, gold bag hardware, watch and ring. The ray ban sunglasses pale blue gradient lens is the perfect compliment to that pale pink jump suit. The aviator shape does a good job of toughening ray ban store up that pink too.
    That the peaks of red carpet dressing leave A list ladies hankering for high glamour off duty is ray ban aviators no surprise. Fine designer sunglasses are one the first ports of call. Actress Amy Adams is currently the face for MaxMara. But she’s cheap ray ban sunglasses forgoing the house for another Italian legend when it comes to sunglasses though here.Shopping with the family in Los Angeles she’s wearing Bulgari Ray Ban Sunglassses

  3. Burial will follow in Peninsula Memorial Park. The family wishes to thank Dr. Frank Huffman, the nursing staff and the Newport News Baptist Retirement Community for the love and concern she received. Our global image is being questioned. Our democracy is being questioned. After the total lockdown, we are Coach Outlet Store unable to provide them 4G connections.

    The geobody dimensions appear to be related to the strain magnitude of the strike slip faults. Coach Outlet We propose that these identified New Jordan Shoes 2020 links and controls are applicable to structurally controlled dolomitization on a more general basis. Our study has demonstrated the potential for using drones in carbonate geological studies..

    People who intentionally starve themselves suffer from an eating disorder called anorexia nervosa. The disorder, which usually begins in young people around the time of puberty, Coach Handbags Clearance involves extreme weight loss that is Ray Ban Outlet less Yeezy Boost 350 than what is considered minimally normal.People with the disorder will often look emaciated, but are convinced that they are overweight. Sometimes they must be hospitalized Ray Ban Glasses in order to prevent starvation.People with anorexia typically starve themselves, Yeezy Discount even though they terribly suffer from hunger pains.

  4. Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great

  5. A debt of gratitude is in order for your post. I've been contemplating composing an extremely tantamount post in the course of the last couple of weeks, I'll most likely keep it straightforward and connection to this rather if thats cool. Much obliged.미프진

  6. However, 3D printing remains to be a extra affordable method to manufacture parts or create models when compared to with} traditional methods. 3D printing is a course of where physical, three-dimensional objects are made layer-by-layer from a digital file. In this two-part webinar series, we discuss how 3D printing might help you Duvet Covers produce extra, increase the quality, and scale back value of|the worth of} your jigs, fixtures, and manufacturing aids. We may also focus on a number of} buyer success stories, properly as|in addition to} the Stratasys printer and material portfolio.