2012-05-14 3 views
1

첫 번째 문이 구문 오류입니까?T-SQL 실행 문 구문 오류

-- this does not work: "incorrect syntax near the keyword 'system_user'" 
exec dbo.spEmployee_GetRecords @pLoginName = system_user 

-- this works 
declare @p nvarchar(30); 
select @p=system_user 
exec dbo.spEmployee_GetRecords @pLoginName = @p 

(SQL 서버 2005 익스프레스 에디션)

답변

4

이것은 EXECUTE의 구문입니다. 함수 나 표현식이 아닌 값이나 변수 만 전달할 수 있습니다. BOL의 EXECUTE을 참조하십시오.

+0

당신 말이 맞습니다. $ (insert-any-programming-language)에서의 함수 호출과의 유사점은 저를 그릇 인도하였습니다. 근본적인 디자인 결정에 대해 궁금해합니다 ... –