is it possible to replace While loop by cte ?

  • HI Folks,

    Is it possible to replace while loop by CTE?

    I will fetch records from table 1 based on tretmentid.

    get the count of records

    run the while loop

    inside loop i will compare the column values with the same table(table 1) for different tretmentid.

    if any one row matches will come out from loop and send status .

    can it be replaced by CTE ?

    Regards,

    Ravi

  • ravi@sql (8/11/2015)


    HI Folks,

    Is it possible to replace while loop by CTE?

    I will fetch records from table 1 based on tretmentid.

    get the count of records

    run the while loop

    inside loop i will compare the column values with the same table(table 1) for different tretmentid.

    if any one row matches will come out from loop and send status .

    can it be replaced by CTE ?

    Regards,

    Ravi

    Maybe. But without seeing your code, can't say for sure.

    By the way, a CTE is just a glorified subquery, nothing more.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

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

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