May 2020
Beginner
564 pages
14h 9m
English
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 <= 10BEGIN 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.
Read now
Unlock full access