aspnet_Users_CreateUser
ALTER PROCEDURE [dbo].aspnet_Users_CreateUser
@ApplicationId UNIQUEIDENTIFIER,
@UserName NVARCHAR(256),
@IsUserAnonymous BIT,----是否匿名用户
@LastActivityDate DATETIME,----最近活动时间
@UserId UNIQUEIDENTIFIER OUTPUT---输出参数
AS
BEGIN
IF( @UserId IS NULL )
SELECT @UserId = NEWID()----函数自动生成
/*对于每台计算机,由 NEWID 返回的值不同。所显示的数字仅起解释说明的作用。*/
ELSE
BEGIN
IF( EXISTS( SELECT UserId FROM dbo.aspnet_Users
WHERE @UserId = UserId ) )
RETURN -1
/*如果ID不为空,且查询表中存在此ID的话,返回-1(存在就不能插入,所以返回-1)*/
END
/*不存在就开始插入数据,然后返回0*/
INSERT dbo.aspnet_Users (ApplicationId, UserId, UserName, LoweredUserName, IsAnonymous, LastActivityDate)
VALUES (@ApplicationId, @UserId, @UserName, LOWER(@UserName), @IsUserAnonymous, @LastActivityDate)
![](/Images/OutliningIndicators/None.gif)
RETURN 0
END
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)