不用写成 if @i=1 OR @i=2 OR ... 这么蠢

原来Transact-SQL可以这样写:


declare @i int;
set @i = 0;
if @i in(1,2,3,4)
    select 'OK';
else
    select 'oh god';

 

结果显示: oh god.

 

这说明,不用写成 if @i=1 OR @i=2 OR ... 这么蠢。

posted on 2010-06-29 11:31  左直拳  阅读(116)  评论(0编辑  收藏  举报

导航