我有一個存儲過程,如下圖所示:存儲過程的問題 - 不能同時獲得返回值
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
我的問題是,當我執行存儲過程,我不能同時獲得返回值,我只得到我先放的那個的返回值。它們在第一次放置時都工作,但第二次返回NULL值。
任何想法我做錯了什麼?
預先感謝
謝謝,這工作的一種享受! – JackofAll 2013-03-06 11:07:14