注册 登录
编程论坛 SQL Server论坛

case 语句问题

烟雨袅袅 发布于 2010-08-12 04:34, 513 次点击
mssql 表table1 有字段 Year,和Month
另传入参数@Month
select * from  table1 where Year =2011 and case @Month when '' then '' else Month end=@Month
 语句里什么意思
 
附:
declare   @Month   varchar(10)
set    @Month=''
select * from  table1 where Year like '%2011%' and  case @Month when '' then '' else Month end=@Month-- 语句一
select * from  table1 where Year like '%2011%' and  Month=@Month-- 语句二
语句一与语句二执行结果是不一样的,


[ 本帖最后由 烟雨袅袅 于 2010-8-12 04:38 编辑 ]
2 回复
#2
烟雨袅袅2010-08-12 05:19
问题解决
#3
cnfarer2010-08-12 08:00
这个问题应该能看出来!
1