Flow control in SQL Server 

SQL Server has IF/ELSE, CASE, and WHILE statements for flow control options. For the IF/ELSE example we used in MySQL, you would need to use a CASE statement in SQL Server.

The WHILE has different syntax, as shown in the following query: 

DECLARE @counter INT = 1;
WHILE @counter <= 10
BEGIN
PRINT @counter;
SET @counter = @counter + 1;
END

The WHILE loop will print 1 through 10.

Also, in SQL Server, you can use a WHILE statement in any query, and it doesn't have to be contained in a stored procedure. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.196.175