zoukankan      html  css  js  c++  java
  • aspnet_Membership_FindUsersByName

    ALTER  PROCEDURE dbo.aspnet_Membership_FindUsersByName
        
    @ApplicationName       NVARCHAR(256),
        
    @UserNameToMatch       NVARCHAR(256),
        
    @PageIndex             INT,
        
    @PageSize              INT
    AS
    BEGIN
        
    DECLARE @ApplicationId UNIQUEIDENTIFIER
        
    SELECT  @ApplicationId = NULL
        
    SELECT  @ApplicationId = ApplicationId FROM dbo.aspnet_Applications WHERE LOWER(@ApplicationName= LoweredApplicationName
        
    IF (@ApplicationId IS NULL)
            
    RETURN 0
       
        
    -- Set the page bounds
        DECLARE @PageLowerBound INT
        
    DECLARE @PageUpperBound INT
        
    DECLARE @TotalRecords   INT
        
    SET @PageLowerBound = @PageSize * @PageIndex
        
    SET @PageUpperBound = @PageSize - 1 + @PageLowerBound

        
    -- Create a temp table TO store the select results
        CREATE TABLE #PageIndexForUsers
        (
            IndexId 
    int IDENTITY (01NOT NULL,
            UserId 
    UNIQUEIDENTIFIER
        )
         
        
    /*此条基本一样,就是条件换成用户名而已,不过好象少了判断用户名是否为空.直接插了.
           按用户名排序
    */

        
    -- Insert into our temp table
        INSERT INTO #PageIndexForUsers (UserId)
            
    SELECT u.UserId
            
    FROM   dbo.aspnet_Users u, dbo.aspnet_Membership m
            
    WHERE  u.ApplicationId = @ApplicationId AND m.UserId = u.UserId AND u.LoweredUserName LIKE LOWER(@UserNameToMatch)
            
    ORDER BY u.UserName


        
    SELECT  u.UserName, m.Email, m.PasswordQuestion, m.Comment, m.IsApproved,
                m.CreateDate,
                m.LastLoginDate,
                u.LastActivityDate,
                m.LastPasswordChangedDate,
                u.UserId, m.IsLockedOut,
                m.LastLockoutDate
        
    FROM   dbo.aspnet_Membership m, dbo.aspnet_Users u, #PageIndexForUsers p
        
    WHERE  u.UserId = p.UserId AND u.UserId = m.UserId AND
               p.IndexId 
    >= @PageLowerBound AND p.IndexId <= @PageUpperBound
        
    ORDER BY u.UserName

        
    SELECT  @TotalRecords = COUNT(*)
        
    FROM    #PageIndexForUsers
        
    RETURN @TotalRecords  ---后面基本一样
    END
  • 相关阅读:
    P2730 魔板 Magic Squares
    P2124 奶牛美容
    4. Median of Two Sorted Arrays(Array; Divide-and-Conquer)
    3.Longest Substring Without Repeating Characters(string; HashTable)
    2.Add Two Numbers (List)
    1.Two Sum (Array; HashTable)
    C++中的浅拷贝、深拷贝、智能指针
    C++ 静态数据成员和静态成员函数
    C & C++ 宏与const
    C++指针与引用
  • 原文地址:https://www.cnblogs.com/ruanbl/p/490048.html
Copyright © 2011-2022 走看看