I am doing a simple 'select' into a variable but not able to understand the output of second snippet.
Working as expected:
declare @tname as varchar(100) = 'F99Special_DMT';
select top(1) @tname = form_name
from [dbo].[forms]
where form_name > @tname
print @tname; -- output = F99Special_Physical
forms table has rows ordered by form_name. F99Special_Physical is the value of last row.
declare @tname as varchar(100) = 'F99Special_Physical';
select top(1) @tname = form_name
from [dbo].[forms]
where form_name > @tname
print @tname; -- output = F99Special_Physical
Shouldn't it output null?
Thanks.