SQL Scalar Variables

SQL scalar variables (otherwise known as local scalar variables) must be defined with type and set to a value before the variable can be used. This can be done in two steps or as a single step.

-- Two steps
DECLARE @count int
SET @count = 0
-- Single step
DECLARE @count int = 0;

-- Another single step declaration where we initialize with a SELECT statement.
DECLARE @jobid uniqueidentifier = (
    SELECT j.ID
    FROM [core].[Job] j
    JOIN [core].[TriggerScheduled] t
    ON j.TriggerID = t.ID
    WHERE j.Name = 'target name')

Additional Links