Skip to the content.

If you definitely haven’t assigned a value to a scalar variable, then: doing something with the value (that isn’t there) is probably not what you intended.

Assign a value to the variable!

(the value will implicitly be null, but… you probably meant it to be something else; if not: just use the null literal)

Bad:

declare @i int;
select @i;

Good:

declare @i int;
set @i = 42;
select @i;