SQL Database Creation · Module 6

Transact-SQL Statements - Quiz Explanation

Self-study assessment
 

Transact-SQL Statements - Quiz Results

Basic Elements of a Transact-SQL Statement

Explanation of answers
The answers you selected are indicated below, along with text that explains the correct answers.
1. Which keyword would you use to assign a static value to the @LoopCounter variable?
Please select the best answer.
  A. UPDATE
  B. RETURN
  C. SET
  D. ASSIGN
  The correct answer is C. To assign a static value to the @LoopCounter variable, you would use the SET keyword. A is incorrect because the UPDATE keyword is used to issue a query update to the database. B is incorrect because the RETURN keyword is used to exit from a procedure. D is incorrect because ASSIGN is not a valid keyword.

2. Which keyword would you use if you wanted to cycle through Transact-SQL statements until specific conditions return TRUE or FALSE?
Please select the best answer.
  A. WHILE
  B. GO
  C. BEGIN
  D. GOTO
  The correct answer is A. To cycle through Transact-SQL statements until specific conditions return TRUE or FALSE, use the WHILE keyword. B is incorrect because the GO keyword is used to issue a Transact-SQL statement to SQL Server. C is incorrect because the BEGIN keyword is used to start a statement block. D is incorrect because the GOTO keyword directs SQL Server to a specific label in your Transact-SQL procedures.
3. What keyword do you use to indicate to SQL Server that you wish to use a variable in your Transact-SQL procedures?
Please select the best answer.
  A. VARIABLE
  B. USE
  C. DECLARE
  D. SELECT
  The correct answer is C. Before you use a variable within your Transact-SQL statements, you must first declare it with the DECLARE keyword. A is incorrect because the VARIABLE keyword is invalid. B is incorrect because the USE keyword indicates to SQL Server to use a specific database. D is close, but incorrect, because you cannot use a SELECT keyword on a variable that is not declared yet.

Return to the assessment