How to Work With WHILE Statements in Transact-SQL
In this article I am going to explain how to work with while statements in T SQL.
Transact-SQL (T-SQL) is Structured Query Language and it is Microsoft's and Sybase's proprietary. Transact-SQL is originally developed by IBM for querying, altering and defining relational database. Transact SQL is also known as T-SQL. T-SQL supports many feature like variables, loops, conditions and exceptions.
While statements execute a sequence of statements multiple times. Statements in the while body are executed as long as a condition is true.
declare @num int
declare @countr int=1
declare @temp int
declare @result varchar(15)
select @num = 2
select @temp = @num*@countr
select @countr = @countr + 1