AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Sql server if statement10/21/2023 ![]() ![]() Set the variable to 5, 50, and 500 to test each statement. The following example shows how an IF … ELSE statement can be nested inside another. PRINT 'Average weight of the Touring-3000 bikes is ' + AS varchar(8)) + '.' PRINT 'The average weight of the top 5 Touring-3000 bikes is ' + AS varchar(8)) + '.' PRINT 'There are ' + AS varchar(3)) + ' Touring-3000 bikes.' (SELECT COUNT(*) FROM Production.Product WHERE Name LIKE 'Touring-3000%' ) > 5 If no conditions are true, it returns the value in the ELSE clause. So, once a condition is true, it will stop reading and return the result. Each statement block starts with BEGIN and completes with END. The CASE statement goes through conditions and returns a value when the first condition is met (like an if-then-else statement). The following example executes a query as part of the Boolean expression and then executes slightly different statement blocks based on the result of the Boolean expression.
0 Comments
Read More
Leave a Reply. |