我有一个存储过程,如下所示:
ALTER PROCEDURE [dbo].[CreateNewLeague]
-- Add the parameters for the stored procedure here
@UserId uniqueidentifier,
@LeagueName VARCHAR(256),
@leagueId Int OUTPUT,
@teamId Int OUTPUT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT @teamId = [teamID] FROM [UserTeam] WHERE (userID = @UserId)
RETURN @teamID
END
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
INSERT INTO League([leagueAdminID], [leagueName]) VALUES (@UserId, @LeagueName)
SELECT SCOPE_IDENTITY()
Set @leagueId = SCOPE_IDENTITY()
RETURN @leagueId
END
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
INSERT INTO LeagueTeam([leagueID], [teamID]) VALUES (@leagueId, @teamID)
END
我的问题是,当我执行 SPROC 时,我无法同时获得两个返回值,我只能获得我放在第一个的返回值。当它们放在第一位时它们都可以工作,但第二个返回一个 NULL 值。
任何想法我做错了什么?
提前致谢