开发者

Can you pass the result of a function as parameter to stored procedure?

Using SqlServer 2005, is it possi开发者_如何学JAVAble to do something like this where SomeFunction returns a value. Eg 1234

EXEC [dbo].[SomeStoredProcedure] @SomeParameter = SomeFunction()


You will need to declare a variable first to hold the result of the function. You can then pass the variable to the stored procedure

Declare @FunctionResult int

Select @FunctionResult = dbo.YourFunction()

Exec dbo.YourStoredProcedure @FunctionResult


Seems I don't have enough reputation to comment on the accepted answer.

Here's a more concise syntax where the declaration and the assignation of the variable is done in one line:

Declare @FunctionResult int = dbo.YourFunction()

Exec dbo.YourStoredProcedure @FunctionResult
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜