我正在对变量进行简单的"选择"但不能理解第二个片段的输出.
按预期工作:
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
Run Code Online (Sandbox Code Playgroud)
表格表格具有按form_name排序的行.F99Special_Physical是最后一行的值.
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
Run Code Online (Sandbox Code Playgroud)
它不应该输出null吗?
谢谢.