1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to SQL Server

Exercise

DECLARE and SET a variable

Using variables makes it easy to run a query multiple times, with different values, without having to scroll down and amend the WHERE clause each time. You can quickly update the variable at the top of the query instead. This also helps provide greater security, but that is out of scope of this course.

Let's go back to the now very familiar grid table for this exercise, and use it to practice extracting data according to your newly defined variable.

Instructions 1/3

undefined XP
    1
    2
    3
  • DECLARE the variable @region, which has a data type of VARCHAR and length of 10.