请教存储过程的多个输出
ALTER PROCEDURE [dbo].[select_stu_Valid]
(
@UserId varchar(50),
@ISValid varChar(12) OUTPUT)
AS
IF EXISTS(SELECT s_userguid FROM mytable WHERE s_userguid = @UserId)
SELECT @ISValid = 'yes '
ELSE
SELECT @ISValid = 'no '
这个存储过程是意思是判断s_userguid 是否为空。为空的话输出no,不为空的话输出yes。
但是我想在这个存储过程中如果s_userguid 非空的话再将一个字段s_ID 取出,这样的话应该怎么改写呢?
[解决办法]
SELECT ISValid = 'no ', s_ID
FROM mytable
[解决办法]
ALTER PROCEDURE [dbo].[select_stu_Valid]
(
@UserId varchar(50)
AS
IF EXISTS(SELECT s_userguid FROM mytable WHERE s_userguid = @UserId)
SELECT 'yes ', s_ID FROM mytable WHERE s_userguid = @UserId
ELSE
SELECT 'no '
[解决办法]
ALTER PROCEDURE [dbo].[select_stu_Valid]
(
@UserId varchar(50),
@s_ID varchar(50) output,
@ISValid varChar(12) OUTPUT)
AS
IF EXISTS(SELECT s_userguid ,@s_ID=s_ID FROM mytable WHERE s_userguid = @UserId)
SELECT @ISValid = 'yes '
ELSE
SELECT @ISValid = 'no '