【发布时间】:2017-07-07 03:20:26
【问题描述】:
select t1.customer_code as doc_num, CONVERT(VARCHAR,t2.created_on,103) as doc_date,
t2.sap_cardcode as sap_doc_num ,t2.void_flg,t2.status_ind,t2.err_msg
from customer t1
inner join sap_customer t2 on t1.id = t2.customer_id
where t2.status_ind = case when @test = 'todo' then t2.status_ind='1' else t2.status_ind='0' END
上面是我需要做的 select 语句,基于 where 语句我需要传递一个参数来确定它应该执行哪个想要。 状态 Ind = 1 或状态 Ind = 0
【问题讨论】:
-
您遇到的错误是什么?
-
"=" 附近的语法不正确
-
在 WHERE 子句中使用 AND/OR 而不是 case 表达式通常会更好。
标签: sql sql-server-2008 case