#title Where절의 실행순서 [[TableOfContents]] 가끔씩 where의 실행 또는 해석순서에 대해 묻곤한다. 묻지말고 해 볼 수 있는 것은 해봐라. 실행은 항상 엄청난 힘을 갖는다. ==== 예제1: 에러 ==== {{{ ;with temp as ( select '1' num union all select 'null' ) select * from temp where 1=1 and convert(int, num) > 0 and isnumeric(num) = 1 /* 메시지 245, 수준 16, 상태 1, 줄 2 varchar 값 'null'을(를) 데이터 형식 int(으)로 변환하지 못했습니다. */ }}} ==== 예제2: 정상 ==== where절의 조건들의 순서를 바꿨다. {{{ ;with temp as ( select '1' num union all select 'null' ) select * from temp where 1=1 and isnumeric(num) = 1 -- 순서를 바꿨다 and convert(int, num) > 0 -- 순서를 바꿨다 }}}