This set of SQL Server Multiple Choice Questions & Answers (MCQs) focuses on “Procedural Flow”.
1. Which of the following language is used for procedural flow in SQL Server?
a) Flow language
b) Control language
c) Control-of-flow language
d) None of the mentioned
View Answer
Explanation: Transact-SQL provides special words called control-of-flow language that control the flow of execution of Transact-SQL statements.
2. Point out the correct statement.
a) Control-of-flow language permits statements to be connected, related to each other, and made interdependent using programming-like constructs
b) Control-of-flow statements cannot span multiple batches, user-defined functions, or stored procedures
c) Control-of-flow words are useful when you need to direct Transact-SQL to take some kind of action
d) All of the mentioned
View Answer
Explanation: Without control-of-flow language, separate Transact-SQL statements are performed sequentially, as they occur.
3. Which of the following is a control flow keyword?
a) IF
b) GO
c) GOTO
d) All of the mentioned
View Answer
Explanation: The Transact-SQL statement or statements that follow GOTO are skipped and processing continues at the label.
4. Which of the following code snippet is valid control flow statement?
a)
IF (@@Error 0) ROLLBACK ELSE COMMIT END
b)
IF (@@Error 0) ROLLBACK
c)
IF (@@Error 0) ROLLBACK ELSE END
d) All of the mentioned
View Answer
Explanation: When the IF test evaluates to false, the optional ELSE portion of the statement lets an alternative T-SQL statement execute.
5. Point out the wrong statement.
a) GOTO can exist within conditional control-of-flow statements, statement blocks, or procedures
b) GOTO permissions need not be granted to any user
c) GOTO statements can be nested
d) None of the mentioned
View Answer
Explanation: GOTO permissions default to any valid user.
6. Which of the following two Transact-SQL statements are commonly used with WHILE?
a) BREAK and CONTINUE
b) BREAK and IF
c) IF and ELSE
d) All of the mentioned
View Answer
Explanation: The BREAK statement exits the innermost WHILE loop and the CONTINUE statement restarts a WHILE loop.
7. Which of the following scenario makes use of BEGIN..END keyword redundant?
a) when an IF statement controls the execution of multiple Transact-SQL statement
b) when an IF statement controls the execution of only one Transact-SQL statement
c) when an IF statement controls the execution of one or more Transact-SQL statement
d) none of the mentioned
View Answer
Explanation: Use the BEGIN and END statements anywhere a control-of-flow statement must execute a block of two or more Transact-SQL statements.
8. The BEGIN and END statements are used when ____________
a) A WHILE loop needs to include a block of statements
b) An element of a CASE expression needs to include a block of statements
c) An IF or ELSE clause needs to include a block of statements
d) All of the mentioned
View Answer
Explanation: A BEGIN and END statement block must contain at least one Transact-SQL statement.
9. Which of the following components constitutes use CASE expression?
a) The primary key name to transform
b) The BEGIN keyword
c) The CASE keyword
d) Where clause defining an alias for the CASE expression
View Answer
Explanation: A common use of the CASE expression is to replace codes or abbreviations with more readable values.
10. The following code snippet uses the DELAY keyword to wait for ______ seconds.
WAITFOR DELAY '00:00:02'; SELECT BusinessEntityID FROM AdventureWorks2008R2.HumanResources.Employee;
a) 2
b) 3
c) 4
d) 5
View Answer
Explanation: The DELAY keyword followed by a time_to_pass before completing the WAITFOR statement. The time to wait before completing the WAITFOR statement can be up to 24 hours.
Sanfoundry Global Education & Learning Series – SQL Server.
To practice all areas of SQL Server, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check SQL Server Books
- Practice Programming MCQs
- Check Information Technology Books
- Apply for Programming Internship