请考虑以下T-sql代码段:
CREATE PROC dbo.SquareNum(@i INT OUTPUT) AS BEGIN SET @i = @i * @i --SELECT @i END GO DECLARE @a INT = 3,@b INT = 5 EXEC dbo.SquareNum @a OUTPUT EXEC dbo.SquareNum @b SELECT @a AS ASQUARE,@b AS BSQUARE GO DROP PROC dbo.SquareNum
结果集是:
ASQUARE BSQUARE ----------- ----------- 9 5
可以看出,@ b不是平方,b / c它没有作为输出参数传入(传入参数时没有OUTPUT限定符).
我想知道是否有一种方法可以检查存储过程体(在本例中为dbo.SquareNum体),以查看参数是否确实已作为OUTPUT参数传入?
解决方法
------ THIS WILL GIVE YOU THE BOTH VALUE IN squared------ CREATE PROC dbo.SquareNum(@i INT OUTPUT) AS BEGIN SET @i = @i * @i --SELECT @i END GO DECLARE @a INT = 3,@b INT = 5 EXEC dbo.SquareNum @a OUTPUT EXEC dbo.SquareNum @b OUTPUT SELECT @a AS ASQUARE,@b AS BSQUARE GO DROP PROC dbo.SquareNum -----TO CHECK STORED PROCEDURE BODY----- SELECT OBJECT_NAME(object_id),OBJECT_DEFINITION(object_id) FROM sys.procedures WHERE OBJECT_DEFINITION(object_id) =(SP_NAME)