SQL Server 2005 で
select @var=column1 from table1
との違いselect top 1 column1 from table1
このモデルの select ステートメントに列があるビューに問題があります
select column0, fn(column0) as col from table2
それがfn
戻るselect @var=column1 from table1 where table1.column3=@inputid
これと交換します
select
column0,
(select top 1 column1 from table1 where table1.id = table2.column0) as col
from table2
しかし、結果は以前と同じではありません
order by in を使用する
select top 1 column1 from table1 where table1.id = table2.column0
も効果なし
変更できる理由を知りたい
select top 1 column1 from table1 where table1.id = table2.column0
と同じ結果になります
select @var=column1 from table1 where table1.column3 = @inputid