는 저장 프로 시저의 일부입니다 - @ID = 0
는 다음의 조건을 무시하면 현재케이스를 사용하는 방법 where where conditon tsql?
@ID int
@Col1 int
@Col2 int
Select *
from Table_01 t1
JOIN table_02 t2 on t1.col = t2.col
where
1 = case when @Col1 = 0 then 1 else (case when t2.Col1 = @Col1 then 1 else 0 end) end
AND 1 = case when @Col2 = 0 then 1 else (case when t2.Col2 = @Col2 then 1 else 0 end) end
AND 1 = case when @ID = 0 then 1 else (case when t2.ID = @ID then 1 else 0 end) end
- @ID는 다음의 기준을 만족에 따라 결과를 반환 값이있는 경우
거기에 다른 조건을 추가해야합니다. -
(일치가없는 사촌)if @ID = -1
는 있지만 @ID = 0
처럼 행동한다는
내가 분명히 있습니까 (expresssion을 추가 무시) 어떤 결과를 반환하지 않겠습니까? :(이 마지막 조건이 비장의 다른 두, 다음 순서를 변경해야하는 경우는
이 마지막 조건이 다른 두 가지보다 우선해야합니까? – Thomas
SQL 서버 2005에서'option (recompile)'을 사용하여도 기억이 안나도 완전히 unsargable입니다. –