Introduction
Variables let you store temporary values in your database session. SET statements assign values to these variables so you can use them later in your queries.
DECLARE @variable_name datatype;
SET @variable_name = value;DECLARE @age INT; SET @age = 30;
DECLARE @name VARCHAR(50); SET @name = 'Alice';
DECLARE @total DECIMAL(10,2); SET @total = 99.99;
DECLARE @count INT; SET @count = 5; SELECT @count AS NumberOfItems;
DECLARE and SET statements?DECLARE hold temporary values during query execution.SETSET assigns values to these variables for use later in the query.@count and set its value to 10 in SQL?DECLARE @variable_name TYPE; declares a variable.SET @variable_name = value; assigns the value.DECLARE @x INT;
SET @x = 5;
SET @x = @x + 3;
SELECT @x;
SELECT statement?DECLARE @total INT
SET total = 100;
SELECT @total;
DECLARE @total INT.total without '@', which is incorrect; it should be @total.Pass the test and this pattern moves unknown