Bird
0
0

What will be the result of this SQL code?

medium📝 query result Q4 of 15
SQL - Stored Procedures and Functions
What will be the result of this SQL code?
DECLARE @num INT;
SET @num = 7;
SET @num = @num * 2;
SELECT @num;
A7
B14
C9
DError
Step-by-Step Solution
Solution:
  1. Step 1: Initial assignment

    @num is declared as INT and set to 7.
  2. Step 2: Update value

    @num is updated to @num * 2, which is 7 * 2 = 14.
  3. Final Answer:

    14 -> Option B
  4. Quick Check:

    Multiplying 7 by 2 gives 14. [OK]
Quick Trick: Multiply variable value correctly before SELECT [OK]
Common Mistakes:
  • Assuming the value remains unchanged after SET
  • Confusing addition with multiplication

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes