本文介绍了为什么事件虽然声明给出错误必须在SQL函数中声明标量变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在改变`function`,如:

I am altering `function` like:

ALTER FUNCTION [dbo].[fn_CalculateListing](@Listing TypeListingDatePrice READONLY)
RETURNS TypePreviousListingResult
AS
BEGIN
    DECLARE @tbl_ListingDateDetails TypePreviousListingResult
    RETURN @tbl_ListingDateDetails
END
GO



但是抛出错误:




But throwing error as:

Msg 137, Level 16, State 1, Procedure fn_CalculateListing, Line 6
   Must declare the scalar variable "@tbl_ListingDateDetails".



为什么这个给出错误并要求声明尽管我在使用那个变量之前声明了这个?


Why this giving error and asking for declaration eventhough I have declared that before using that variable?

推荐答案

DECLARE @X INT
SET @X = 3
SELECT @X
GO
SELECT @X

将给出您描述的错误消息。

Will give the error message you describe.


这篇关于为什么事件虽然声明给出错误必须在SQL函数中声明标量变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 18:58
查看更多