我只是想知道为什么会这样。但我所评论的内容并不奏效。
ALTER PROC spFactorial
@ValueIn int,
@ValueOut int OUTPUT
AS
DECLARE @InWorking int;
DECLARE @OutWorking int;
IF @ValueIn <> 1 -- this <= doesn't work??
BEGIN
SELECT @InWorking = @ValueIn - 1;
EXEC spFactorial @InWorking, @OutWorking OUTPUT;
SELECT @ValueOut = @ValueIn * @OutWorking;
END
ELSE
BEGIN
SELECT @ValueOut = 1;
END
RETURN;
GO
DECLARE @WorkingOut int;
DECLARE @WorkingIn int;
SELECT @WorkingIn = 3;
EXEC spFactorial @WorkingIn, @WorkingOut OUTPUT;
PRINT CAST(@WorkingIn AS varchar ) + ' factorial is '
+ CAST(@WorkingOut AS VARCHAR );
此IF @ValueIn <= 1
无效 - 为什么?
在C#或java中它可以工作。
谢谢
答案 0 :(得分:0)
<= is not an operator in SQL. In c# and Java it is.
对于Sql中的&lt; =运算符功能,您可以执行此操作
IF(@value < 1 OR @value = 1)