Question: As we talk about stored procedures (SP) and User Defined Functions (UDF) we can store these objects as part of the database and to call
As we talk about stored procedures (SP) and User Defined Functions (UDF) we can store these objects as part of the database and to call them repeatedly through query editor, scripts we write, third-part applications, etc. One import aspect of both of these is that we tend to write more powerful code for a very specific function and situations. Once such situation is the looping within TSQL. Looping is a powerful construct as it allows us to repeat the same code until a condition is met. Unlike other languages, e.g., VB.net, C#, Java, etc., TSQL is limited to only one type of loop, the WHILE loop. However, if constructed properly, we can simulate the behavior of other loops such as a FOR loop.
I would like you to try and write a WHILE loop that would simulate the behavior of a FOR loop you would see in another language?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
