我正在使用商店程序
即
CREATE PROCEDURE test
(
@INPUTPARAM INT,
@OUTPUTPARAM VARCHAR(20)
)
AS
SELECT @OUTPUTPARAM=S.NAME+','+D.NAME
FROM STUDENT S,DEPARTMENT D
WHERE S.DEPTID=D.DEPARTID AND D.DEPARTID=@INPUTPARAM
BEGIN
END
如何使用休眠从Java类中获取参数
请分享代码示例
最佳答案
CREATE PROCEDURE test
(
@INPUTPARAM INT,
@OUTPUTPARAM VARCHAR(20) OUTPUT --<-- You need to use key word "OUTPUT" here
)
AS
BEGIN
SELECT @OUTPUTPARAM = S.NAME + ',' + D.NAME
FROM STUDENT S INNER JOIN DEPARTMENT D
ON S.DEPTID = D.DEPARTID --<-- Use New Syntax of join with On Clause
WHERE D.DEPARTID = @INPUTPARAM
END
执行程序
DECLARE @Var VARCHAR(20);
EXECUTE dbo.test
@INPUTPARAM = 1
@OUTPUTPARAM = @Var OUTPUT --<-- use OUTPUT key word here as well
SELECT @Var