一个存储过程的返回值的获取问题
存储过程如下:
CREATE PROC AddUser(
@userName varchar(40),
@userPass varchar(40)
)
AS
SET NOCOUNT ON
IF EXISTS(SELECT mu_username from MyUser where mu_username=@userName)
BEGIN
RETURN 0
END
ELSE
BEGIN
INSERT INTO MyUser(mu_username,mu_userpass)values(@username,@userpass)
RETURN 1
END
SET NOCOUNT OFF
***************************************
请问如何获取它的返回值(在查询分析器中)
问题解决,马上给分,谢谢~~
------解决方案------------------------或者这样写
create PROC AddUser(
@userName varchar(40),
@userPass varchar(40),
@num int output
)
AS
SET NOCOUNT ON
IF EXISTS(SELECT mu_username from MyUser where mu_username=@userName)
BEGIN
set @num=0
END
ELSE
BEGIN
INSERT INTO MyUser(mu_username,mu_userpass)values(@username,@userpass)
set @num=1
END
SET NOCOUNT OFF
declare @return_value int
set @return_value = 1
exec AddUser 'a ', 'p ',@return_value output
select @return_value