我在另一个内部调用一个存储过程,由于某种原因,SQL Server 不喜欢我提供的参数。它可能很简单,但我不确定它为什么不喜欢它。
存储过程 1
USE [UserManagerTest]
GO
/****** Object: StoredProcedure [dbo].[sp_UserManager_Log_User_Off] Script Date: 11/19/2012 11:33:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Nick Gowdy
-- Create date: 13-11-2012
-- Description: Used by model is UserManager to filter data returned to code
-- =============================================
ALTER PROCEDURE [dbo].[sp_UserManager_Log_User_Off]
@userid UNIQUEIDENTIFIER
AS
BEGIN
-- Get SessionID from UserID
DECLARE @sessionid VARCHAR(60)
DECLARE @userid uniqueidentifier
select @userid = '61B08729-BB4F-426C-B20B-697F40F458C5'
EXEC @sessionid = aspnet_Membership_Custom_GetUserSessionsByUserId @userid
select @sessionid as sessionid
-- Delete user session based on sessionid and userid
EXEC aspnet_Membership_Custom_DeleteUserSession @sessionid, @userid
END
存储过程 2
USE [UserManagerTest]
GO
/****** Object: StoredProcedure [dbo].[aspnet_Membership_Custom_GetUserSessionsByUserId] Script Date: 11/19/2012 12:16:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[aspnet_Membership_Custom_GetUserSessionsByUserId]
@UserId uniqueidentifier
AS
BEGIN
declare @SessionId varchar(60)
select @SessionId = ( SELECT
[UserId]
FROM
[dbo].[aspnet_Custom_UserSessionActivity]
WHERE
[UserId] = @UserId)
--select @SessionId
RETURN @SessionId
end
当我执行 sp_usermanager_log_user_off 时出现此错误
Msg 245, Level 16, State 1, Procedure aspnet_Membership_Custom_GetUserSessionsByUserId, Line 17
Conversion failed when converting the varchar value '61B08729-BB4F-426C-B20B-697F40F458C5' to data type int.
有任何想法吗?谢谢!