• sushantkatte (8/1/2015)


    Thank You very much @SScrazy for providing the solution. i am very new to the sql server programming and have started learning recently. could you please help me understand the logic of script that you provided and how it works?

    Actually this question was asked to me in an interview

    Now that you have answers, I'm curious... how is it that you're applying for a job that requires knowledge of T-SQL while you have virtually none? Does your resume say that you've worked with T-SQL to any extent? Did you tell the interviewer that you were just getting started in the world of SQL Server?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)