0

我有一个这样的存储过程:

create proc calcaulateavaerage
@studentid int
as
begin

-- some complicated business and query

return @result  -- single decimal value 
end

然后我想

创建 proc 整个结果

select * , ................................ from X where X.value >  (calculateaverage X.Id)

它总是给出一个错误,类似于“无法绑定多部分标识符计算平均值”。知道如何解决吗?

4

2 回答 2

4

您不想要存储过程。你想要一个功能。

于 2013-06-20T18:03:15.400 回答
2

使用输出变量从存储过程中输出数据:

create proc calcaulateavaerage
@studentid int, @result int
as
begin

-- some complecated business and query

select @result = id from sometable;
end

-- Declaring output variable named result;
declare @result int;
-- Passing output variable to stored procedure.
exec calculateaverage 1, @result;

-- Now you can display the result or do whatever you like.
print @result 
于 2013-06-20T18:05:57.693 回答