RT存过B
CREATE proc usp_B
@Id int,
@Error int output
AS
...........
...........
if @@error = 0
begin
SET @nCount = select count(1) from [Table1]
SET @Error = 0
end
else
SET @Error = 1
end
return @nCount
GO
在A中,需要得到@Error,来判断是否继续,如果继续,则需要得到@nCount这个参数。各位帮帮忙,如何才能做到?谢谢了!!!
PS:我在A中Exec @nCountRow = Exec B @id,@Error output
得到的是@Error的值,是正确的,可以进行往下运行。但无法得到return 返回的数值。
CREATE proc usp_B
@Id int,
@Error int output
AS
...........
...........
if @@error = 0
begin
SET @nCount = select count(1) from [Table1]
SET @Error = 0
end
else
SET @Error = 1
end
return @nCount
GO
在A中,需要得到@Error,来判断是否继续,如果继续,则需要得到@nCount这个参数。各位帮帮忙,如何才能做到?谢谢了!!!
PS:我在A中Exec @nCountRow = Exec B @id,@Error output
得到的是@Error的值,是正确的,可以进行往下运行。但无法得到return 返回的数值。
GO
CREATE proc usp_B
@Id int,
@Error int output,
@NCOUNT INT OUTPUT
AS if @@error = 0
begin
select @nCount = count(1) from SYSOBJECTS
SET @Error = 0
end
else
SET @Error = 1 GO
DECLARE
@Error int ,
@NCOUNT INT
EXEC USP_B 1,@ERROR OUTPUT, @NCOUNT OUTPUT
PRINT @ERROR
PRINT @NCOUNT
最好是不动B先谢谢你啊yczealot()
@Error变量是output值
lz可以用
Exec @nCountRow = Exec B @id,@Error output
select @nCountRow
select @Error
查看这两个值
lz的语句要改一下
Exec @nCountRow = B @id,@Error output
---------------------------------
select @nCountRow
select @Error这样就不会出错了
GO
CREATE PROC USP_B
@ID INT,
@ERROR INT OUTPUTAS
declare
@NCOUNT INT IF @@ERROR = 0
BEGIN
SELECT @NCOUNT = COUNT(1) FROM SYSOBJECTS
SET @ERROR = 0
END
ELSE
SET @ERROR = 1 RETURN @NCOUNTGOdeclare
@ERROR INT
declare
@NCOUNT INT EXEC @NCOUNT=USP_B 1,@ERROR OUTPUT
print @ncount
print @error可以啊
USE [OMS_NET]
GODECLARE @return_value int,
@sPK varchar(50)EXEC @return_value = [dbo].[mp_GetPKNo]
@sPK = @sPK OUTPUTSELECT @sPK as N'@sPK'SELECT 'Return Value' = @return_value ---->return返回值GO