Bird
0
0

Which of the following is a correct way to assign a value to a variable in SQL?

easy📝 Conceptual Q2 of 15
SQL - Stored Procedures and Functions
Which of the following is a correct way to assign a value to a variable in SQL?
ASET @var = 10;
BDECLARE @var = 10;
CASSIGN @var 10;
DVALUE @var := 10;
Step-by-Step Solution
Solution:
  1. Step 1: Recall the syntax for assigning values to variables

    In SQL, after declaring a variable, the SET statement is used to assign a value.
  2. Step 2: Identify the correct syntax

    SET @var = 10; is the correct way. Other options use invalid keywords or syntax.
  3. Final Answer:

    SET @var = 10; -> Option A
  4. Quick Check:

    Assign value syntax = SET @var = value [OK]
Quick Trick: Use SET to assign values after DECLARE [OK]
Common Mistakes:
  • Using DECLARE to assign values directly
  • Using non-SQL keywords like ASSIGN or VALUE
  • Incorrect assignment operators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes