Stored Procedure keeps looping until it returns a specific value?

  • Hi,

    So I have a SP that is fairly simple - searches some tables for events/values are either returns 0 or 1 depending on what it finds.

    What is needed is  to have it loop until it returns 0? Ideally at a specified time interval. Not sure of the syntax

    Also, is there any risk to doing it this way (rather than say running the existing SP at the same interval using a batch scheduler solution)?

  • Looping a procedure like that (which is possible, look up a WHILE loop), will lead to all sorts of problems. I wouldn't recommend it at all. Instead, from what you're saying, you need to look up what a trigger is. Then, when something changes from 1 to 0, it automatically does something... I think. Just guessing because the requirements here are pretty vague.

    Don't loop the query.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 2 posts - 1 through 1 (of 1 total)

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