1
我正在做一個簡單的'選擇'成一個變量,但無法理解第二個片段的輸出。TSQL選擇到一個變量
按預期工作:
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
形式的表有由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
不應該輸出空嗎?
謝謝。