sqlserverd的case when 使用

百炼钢丶 2009-07-25 06:02:10

要实现这样的查询

当 入参为 -1 时,不执行此条件,当入参为一个有效的字符串时,执行charindex()判断

case when @sell_plan_type = '-1' then sell_plan_type=sell_plan_type else charindex(sell_plan_type,@sell_plan_type)>0 end)


这样写,报错:
消息 102,级别 15,状态 1,过程 test_proc,第 9 行
'=' 附近有语法错误。


请网友帮忙,或者改写case when,或者用其他语句代替。非常感谢!
...全文
46 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiangshun 2009-07-25
  • 打赏
  • 举报
回复
case when @sell_plan_type = '-1' then sell_plan_type=sell_plan_type else 
charindex(sell_plan_type,@sell_plan_type) end)

22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧