-- 정말 10가지나??? 전 일단 얼핏 생각나는게 2개뿐인데 10개를 목표로 찾아보지요~

-- 인덱스로 이쁘게 해도 되겠지요?

 

 

-- 글제목 : 방어코드(오류512 관련)

-- 작성자 : 차주언(narsas@naver.com)
-- 작성일 : 2009.11.30

 

use pubs

go

 

n  문제있는 쿼리

select authors.au_id from authors where

authors.au_id = (select titleauthor.au_id

from titleauthor)

go

 

--Msg 512, Level 16, State 1, Line 1

--하위쿼리에서값을둘이상반환했습니다. 하위쿼리앞에=, !=, <, <=, >, >= 등이오거나하위쿼리가하나의식으로사용된경우에는여러값을반환할수없습니다.

 

n  문제 생기는게 불가능한 쿼리 (두가지 방법중 한 개로 소스수정)

select authors.au_id from authors where

authors.au_id in (select titleauthor.au_id

from titleauthor)

go

 

select authors.au_id from authors where

authors.au_id = (select top 1 titleauthor.au_id

from titleauthor order by authors.au_id)

go

 





profile

차주언
MSSQL DBA ,  MCT/ MCDBA
SQL프런티어 /