Looking for Input on Use of WHILE Loop In Job Step

  • Jeff Moden (10/20/2009)


    I know that the use of cursors and loops for flow control is an acceptable use but... I just can't bring myself to write one if there is another way that's just as fast.

    First, make it easy on yourself... build a control table that can be populated either manually for ad hoc runs or by some proc somewhere. Here's and example...

    (See orgianl post for Code sample)

    See the following article for more on what a Tally table is an how it works to replace loops...

    http://www.sqlservercentral.com/articles/T-SQL/62867/

    Great idea and I actually had plans to do something similiar to this but I like your example better and so I'm going to use it (as a template) instead.

    Kindest Regards,

    Just say No to Facebook!
  • WOW! Great replies; the perfect reason why I love these Boards!

    First off thanks to all for replying. Seen several great tips in various posts, some of which I had not yet loked at and some I had but have not yet implemented such as using TRY/CATCH.

    I also have within the Job an SP I call that among several custom logging actions will email me upon completion. The Default Job allows for email notification but I prefer using a custom email alert (via SP) so I can customize what info is sent.

    My mine goal was the whole loop vs multiple steps take; moving from multiple Job Steps that have to always be edited verses a dynamic loop. Most of the Looping examples I could find were never used in conjunction with a SQL Job and so that was were I was looking for input on the validity of doing this.

    Thanks again to all.

    Kindest Regards,

    Just say No to Facebook!

Viewing 2 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply