我在使用存储过程时遇到问题,该存储过程将信息从内置的 C# 角色和成员管理表中提取到我自己的自定义表中。该过程在最后一个 Update 语句之前运行良好。
ALTER PROCEDURE [dbo].[GetPerpsectiveMemberList]
AS
DECLARE @Members TABLE
(
RowNumber INT,
PerspectiveMemberID INT,
FirstName varchar(MAX),
LastName varchar(MAX),
[Address] varchar(MAX),
City varchar(MAX),
[State] varchar(MAX),
Zip varchar(MAX),
Email varchar(MAX),
ASPMemberID varchar(MAX),
ASPUsername varchar(MAX),
RoleID2 varchar(MAX),
RoleName2 varchar(MAX)
)
INSERT INTO @Members
SELECT ROW_NUMBER() OVER (ORDER BY Perspective_Member.PerspectiveMemberID), PerspectiveMemberID, Perspective_Member.FirstName, Perspective_Member.LastName,
Perspective_Member.[Address], Perspective_Member.City, Perspective_Member.[State], Perspective_Member.[State], Perspective_Member.Zip, Perspective_Member.ASPMemberID,
Perspective_Member.ASPUsername,PerspectiveMemberID, ASPMemberID
FROM Perspective_Member
UPDATE @Members
SET RoleID2 = aspnet_UsersInRoles.RoleId
FROM aspnet_UsersInRoles
WHERE ASPMemberID = UserId
UPDATE @Members
SET RoleName2 = RoleName
FROM aspnet_Roles
WHERE RoleID2 = RoleID
SELECT * FROM @Members
当程序失败时,我收到此消息
Conversion failed when converting from a character string to uniqueidentifier.
当我搜索此错误消息时,我发现每个人都在从字符串到唯一标识符时遇到问题,但让我发疯的是最后一个块中使用的唯一唯一标识符正在 WHERE 子句中使用,并且我之前说过,只要最后一次 UPDATE bl,程序就会完美运行