Variables

Contents

Variables#

A local variable holds a single value of a given type within a batch. Declare it with DECLARE and assign it with SET or SELECT.

Syntax#

DECLARE @variable_name data_type [ = value ] [ , ...n ]
SET @variable_name = expression

Examples#

DECLARE @id INT = 4;
SET @id = @id + 1;
SELECT @id;

DECLARE @name NVARCHAR(50);
SELECT @name = name FROM dbo.customers WHERE id = @id;

Note

Querona also supports table variables (DECLARE @t TABLE (...)) and temporary tables (#tmp). See Feature support.