CREATE FUNCTION test_function_search (@찾을값 int)
RETURNS varchar(10)
AS
BEGIN
DECLARE @넘기는값 varchar(10)
SET @넘기는값 = '지금은없음'
SELECT @넘기는값 = body
FROM test_table_for_function
WHERE idx = @찾을값
RETURN (@넘기는값)
END
위와 같이 FUNCTION을 하나 만듭니다.
select idx, body, dbo.test_function_search(idx) As fromFunc
from test_table_for_function