Articles → SQL SERVER → Variables In SQL Server
Variables In SQL Server
Purpose
Syntax
DECLARE @variable_name data_type
Setting Values
- Using the "SET" keyword
- Using the "SELECT" query
Using the SET keyword
SET @errormessage = 'Invalid User'
Using the SELECT query
SELECT
@variable_name = [column_Name | Aggregate function]
FROM
table_name
SELECT
@row_count = count(*)
FROM
user_information