Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4329020
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:46:01+00:00 2026-05-21T09:46:01+00:00

I have Stored Procedure that fetch a table records. I am new to Write

  • 0

I have Stored Procedure that fetch a table records.
I am new to Write Stored Procedures.
how can I add paging to this Stored Procedure ?
I’m using Sql Server 2005.
I want to add two more arguments to Stored Procedure.
PageIndex and PageSize.
Please Help.

USE [tadarokatbase]
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[aspnet_Membership_Find]
(
    @SearchUsingOR bit   = null ,

    @ApplicationId uniqueidentifier   = null ,

    @UserId uniqueidentifier   = null ,

    @Password nvarchar (128)  = null ,

    @PasswordFormat int   = null ,

    @PasswordSalt nvarchar (128)  = null ,

    @MobilePin nvarchar (16)  = null ,

    @Email nvarchar (256)  = null ,

    @LoweredEmail nvarchar (256)  = null ,

    @PasswordQuestion nvarchar (256)  = null ,

    @PasswordAnswer nvarchar (128)  = null ,

    @IsApproved bit   = null ,

    @IsLockedOut bit   = null ,

    @CreateDate datetime   = null ,

    @LastLoginDate datetime   = null ,

    @LastPasswordChangedDate datetime   = null ,

    @LastLockoutDate datetime   = null ,

    @FailedPasswordAttemptCount int   = null ,

    @FailedPasswordAttemptWindowStart datetime   = null ,

    @FailedPasswordAnswerAttemptCount int   = null ,

    @FailedPasswordAnswerAttemptWindowStart datetime   = null ,

    @Comment ntext   = null 
)
AS



  IF ISNULL(@SearchUsingOR, 0) <> 1
  BEGIN
    SELECT
      [ApplicationId]
    , [UserId]
    , [Password]
    , [PasswordFormat]
    , [PasswordSalt]
    , [MobilePIN]
    , [Email]
    , [LoweredEmail]
    , [PasswordQuestion]
    , [PasswordAnswer]
    , [IsApproved]
    , [IsLockedOut]
    , [CreateDate]
    , [LastLoginDate]
    , [LastPasswordChangedDate]
    , [LastLockoutDate]
    , [FailedPasswordAttemptCount]
    , [FailedPasswordAttemptWindowStart]
    , [FailedPasswordAnswerAttemptCount]
    , [FailedPasswordAnswerAttemptWindowStart]
    , [Comment]
    FROM
    [dbo].[aspnet_Membership]
    WHERE 
     ([ApplicationId] = @ApplicationId OR @ApplicationId IS NULL)
    AND ([UserId] = @UserId OR @UserId IS NULL)
    AND ([Password] = @Password OR @Password IS NULL)
    AND ([PasswordFormat] = @PasswordFormat OR @PasswordFormat IS NULL)
    AND ([PasswordSalt] = @PasswordSalt OR @PasswordSalt IS NULL)
    AND ([MobilePIN] = @MobilePin OR @MobilePin IS NULL)
    AND ([Email] = @Email OR @Email IS NULL)
    AND ([LoweredEmail] = @LoweredEmail OR @LoweredEmail IS NULL)
    AND ([PasswordQuestion] = @PasswordQuestion OR @PasswordQuestion IS NULL)
    AND ([PasswordAnswer] = @PasswordAnswer OR @PasswordAnswer IS NULL)
    AND ([IsApproved] = @IsApproved OR @IsApproved IS NULL)
    AND ([IsLockedOut] = @IsLockedOut OR @IsLockedOut IS NULL)
    AND ([CreateDate] = @CreateDate OR @CreateDate IS NULL)
    AND ([LastLoginDate] = @LastLoginDate OR @LastLoginDate IS NULL)
    AND ([LastPasswordChangedDate] = @LastPasswordChangedDate OR @LastPasswordChangedDate IS NULL)
    AND ([LastLockoutDate] = @LastLockoutDate OR @LastLockoutDate IS NULL)
    AND ([FailedPasswordAttemptCount] = @FailedPasswordAttemptCount OR @FailedPasswordAttemptCount IS NULL)
    AND ([FailedPasswordAttemptWindowStart] = @FailedPasswordAttemptWindowStart OR @FailedPasswordAttemptWindowStart IS NULL)
    AND ([FailedPasswordAnswerAttemptCount] = @FailedPasswordAnswerAttemptCount OR @FailedPasswordAnswerAttemptCount IS NULL)
    AND ([FailedPasswordAnswerAttemptWindowStart] = @FailedPasswordAnswerAttemptWindowStart OR @FailedPasswordAnswerAttemptWindowStart IS NULL)

  END
  ELSE
  BEGIN
    SELECT
      [ApplicationId]
    , [UserId]
    , [Password]
    , [PasswordFormat]
    , [PasswordSalt]
    , [MobilePIN]
    , [Email]
    , [LoweredEmail]
    , [PasswordQuestion]
    , [PasswordAnswer]
    , [IsApproved]
    , [IsLockedOut]
    , [CreateDate]
    , [LastLoginDate]
    , [LastPasswordChangedDate]
    , [LastLockoutDate]
    , [FailedPasswordAttemptCount]
    , [FailedPasswordAttemptWindowStart]
    , [FailedPasswordAnswerAttemptCount]
    , [FailedPasswordAnswerAttemptWindowStart]
    , [Comment]
    FROM
    [dbo].[aspnet_Membership]
    WHERE 
     ([ApplicationId] = @ApplicationId AND @ApplicationId is not null)
    OR ([UserId] = @UserId AND @UserId is not null)
    OR ([Password] = @Password AND @Password is not null)
    OR ([PasswordFormat] = @PasswordFormat AND @PasswordFormat is not null)
    OR ([PasswordSalt] = @PasswordSalt AND @PasswordSalt is not null)
    OR ([MobilePIN] = @MobilePin AND @MobilePin is not null)
    OR ([Email] = @Email AND @Email is not null)
    OR ([LoweredEmail] = @LoweredEmail AND @LoweredEmail is not null)
    OR ([PasswordQuestion] = @PasswordQuestion AND @PasswordQuestion is not null)
    OR ([PasswordAnswer] = @PasswordAnswer AND @PasswordAnswer is not null)
    OR ([IsApproved] = @IsApproved AND @IsApproved is not null)
    OR ([IsLockedOut] = @IsLockedOut AND @IsLockedOut is not null)
    OR ([CreateDate] = @CreateDate AND @CreateDate is not null)
    OR ([LastLoginDate] = @LastLoginDate AND @LastLoginDate is not null)
    OR ([LastPasswordChangedDate] = @LastPasswordChangedDate AND @LastPasswordChangedDate is not null)
    OR ([LastLockoutDate] = @LastLockoutDate AND @LastLockoutDate is not null)
    OR ([FailedPasswordAttemptCount] = @FailedPasswordAttemptCount AND @FailedPasswordAttemptCount is not null)
    OR ([FailedPasswordAttemptWindowStart] = @FailedPasswordAttemptWindowStart AND @FailedPasswordAttemptWindowStart is not null)
    OR ([FailedPasswordAnswerAttemptCount] = @FailedPasswordAnswerAttemptCount AND @FailedPasswordAnswerAttemptCount is not null)
    OR ([FailedPasswordAnswerAttemptWindowStart] = @FailedPasswordAnswerAttemptWindowStart AND @FailedPasswordAnswerAttemptWindowStart is not null)
    SELECT @@ROWCOUNT           
  END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:46:02+00:00Added an answer on May 21, 2026 at 9:46 am

    This may help:

    USE [tadarokatbase]
    GO
    
    SET ANSI_NULLS OFF
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[aspnet_Membership_Find]
    (
        @SearchUsingOR bit   = null ,
        @ApplicationId uniqueidentifier   = null ,
        @UserId uniqueidentifier   = null ,
        @Password nvarchar (128)  = null ,
        @PasswordFormat int   = null ,
        @PasswordSalt nvarchar (128)  = null ,
        @MobilePin nvarchar (16)  = null ,
        @Email nvarchar (256)  = null ,
        @LoweredEmail nvarchar (256)  = null ,
        @PasswordQuestion nvarchar (256)  = null ,
        @PasswordAnswer nvarchar (128)  = null ,
        @IsApproved bit   = null ,
        @IsLockedOut bit   = null ,
        @CreateDate datetime   = null ,
        @LastLoginDate datetime   = null ,
        @LastPasswordChangedDate datetime   = null ,
        @LastLockoutDate datetime   = null ,
        @FailedPasswordAttemptCount int   = null ,
        @FailedPasswordAttemptWindowStart datetime   = null ,
        @FailedPasswordAnswerAttemptCount int   = null ,
        @FailedPasswordAnswerAttemptWindowStart datetime   = null ,
        @Comment ntext   = null ,
    
    
        @StartRowIndex      int = null,
        @PageSize           int = null
    
    )
    
    AS
    
        Declare @UpperBand int
        Declare @LowerBand int
    
    
      IF ISNULL(@SearchUsingOR, 0) <> 1
      BEGIN
    
      SET @LowerBand  = @startRowIndex
      SET @UpperBand  = @startRowIndex + @pageSize
    
        WITH tempPagedEntities AS
                (
        SELECT
          [ApplicationId]
        , [UserId]
        , [Password]
        , [PasswordFormat]
        , [PasswordSalt]
        , [MobilePIN]
        , [Email]
        , [LoweredEmail]
        , [PasswordQuestion]
        , [PasswordAnswer]
        , [IsApproved]
        , [IsLockedOut]
        , [CreateDate]
        , [LastLoginDate]
        , [LastPasswordChangedDate]
        , [LastLockoutDate]
        , [FailedPasswordAttemptCount]
        , [FailedPasswordAttemptWindowStart]
        , [FailedPasswordAnswerAttemptCount]
        , [FailedPasswordAnswerAttemptWindowStart]
        , [Comment]
    
        ,ROW_NUMBER() OVER (ORDER BY UserId asc ) as RowNumber
    
        FROM
        [dbo].[aspnet_Membership]
        WHERE 
         ([ApplicationId] = @ApplicationId OR @ApplicationId IS NULL)
        AND ([UserId] = @UserId OR @UserId IS NULL)
        AND ([Password] = @Password OR @Password IS NULL)
        AND ([PasswordFormat] = @PasswordFormat OR @PasswordFormat IS NULL)
        AND ([PasswordSalt] = @PasswordSalt OR @PasswordSalt IS NULL)
        AND ([MobilePIN] = @MobilePin OR @MobilePin IS NULL)
        AND ([Email] = @Email OR @Email IS NULL)
        AND ([LoweredEmail] = @LoweredEmail OR @LoweredEmail IS NULL)
        AND ([PasswordQuestion] = @PasswordQuestion OR @PasswordQuestion IS NULL)
        AND ([PasswordAnswer] = @PasswordAnswer OR @PasswordAnswer IS NULL)
        AND ([IsApproved] = @IsApproved OR @IsApproved IS NULL)
        AND ([IsLockedOut] = @IsLockedOut OR @IsLockedOut IS NULL)
        AND ([CreateDate] = @CreateDate OR @CreateDate IS NULL)
        AND ([LastLoginDate] = @LastLoginDate OR @LastLoginDate IS NULL)
        AND ([LastPasswordChangedDate] = @LastPasswordChangedDate OR @LastPasswordChangedDate IS NULL)
        AND ([LastLockoutDate] = @LastLockoutDate OR @LastLockoutDate IS NULL)
        AND ([FailedPasswordAttemptCount] = @FailedPasswordAttemptCount OR @FailedPasswordAttemptCount IS NULL)
        AND ([FailedPasswordAttemptWindowStart] = @FailedPasswordAttemptWindowStart OR @FailedPasswordAttemptWindowStart IS NULL)
        AND ([FailedPasswordAnswerAttemptCount] = @FailedPasswordAnswerAttemptCount OR @FailedPasswordAnswerAttemptCount IS NULL)
        AND ([FailedPasswordAnswerAttemptWindowStart] = @FailedPasswordAnswerAttemptWindowStart OR @FailedPasswordAnswerAttemptWindowStart IS NULL)
    
        )
                SELECT 
                    * 
                FROM 
                    tempPagedEntities 
                WHERE 
                    RowNumber > @LowerBand AND RowNumber <= @UpperBand
    
      END
      ELSE
      BEGIN
    
      BEGIN
                WITH tempPagedEntities AS
                (
        SELECT
          [ApplicationId]
        , [UserId]
        , [Password]
        , [PasswordFormat]
        , [PasswordSalt]
        , [MobilePIN]
        , [Email]
        , [LoweredEmail]
        , [PasswordQuestion]
        , [PasswordAnswer]
        , [IsApproved]
        , [IsLockedOut]
        , [CreateDate]
        , [LastLoginDate]
        , [LastPasswordChangedDate]
        , [LastLockoutDate]
        , [FailedPasswordAttemptCount]
        , [FailedPasswordAttemptWindowStart]
        , [FailedPasswordAnswerAttemptCount]
        , [FailedPasswordAnswerAttemptWindowStart]
        , [Comment]
    
        ,ROW_NUMBER() OVER (ORDER BY UserId asc ) as RowNumber
    
        FROM
        [dbo].[aspnet_Membership]
        WHERE 
         ([ApplicationId] = @ApplicationId AND @ApplicationId is not null)
        OR ([UserId] = @UserId AND @UserId is not null)
        OR ([Password] = @Password AND @Password is not null)
        OR ([PasswordFormat] = @PasswordFormat AND @PasswordFormat is not null)
        OR ([PasswordSalt] = @PasswordSalt AND @PasswordSalt is not null)
        OR ([MobilePIN] = @MobilePin AND @MobilePin is not null)
        OR ([Email] = @Email AND @Email is not null)
        OR ([LoweredEmail] = @LoweredEmail AND @LoweredEmail is not null)
        OR ([PasswordQuestion] = @PasswordQuestion AND @PasswordQuestion is not null)
        OR ([PasswordAnswer] = @PasswordAnswer AND @PasswordAnswer is not null)
        OR ([IsApproved] = @IsApproved AND @IsApproved is not null)
        OR ([IsLockedOut] = @IsLockedOut AND @IsLockedOut is not null)
        OR ([CreateDate] = @CreateDate AND @CreateDate is not null)
        OR ([LastLoginDate] = @LastLoginDate AND @LastLoginDate is not null)
        OR ([LastPasswordChangedDate] = @LastPasswordChangedDate AND @LastPasswordChangedDate is not null)
        OR ([LastLockoutDate] = @LastLockoutDate AND @LastLockoutDate is not null)
        OR ([FailedPasswordAttemptCount] = @FailedPasswordAttemptCount AND @FailedPasswordAttemptCount is not null)
        OR ([FailedPasswordAttemptWindowStart] = @FailedPasswordAttemptWindowStart AND @FailedPasswordAttemptWindowStart is not null)
        OR ([FailedPasswordAnswerAttemptCount] = @FailedPasswordAnswerAttemptCount AND @FailedPasswordAnswerAttemptCount is not null)
        OR ([FailedPasswordAnswerAttemptWindowStart] = @FailedPasswordAnswerAttemptWindowStart AND @FailedPasswordAnswerAttemptWindowStart is not null)
    
        )
                SELECT 
                    * 
                FROM 
                    tempPagedEntities 
                WHERE 
                    RowNumber > @LowerBand AND RowNumber <= @UpperBand
    
        SELECT @@ROWCOUNT           
      END
    
      END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure currently executing a complicated fetch that is frequently timing
I have a stored procedure that returns multiple tables. How can I execute and
I have a stored procedure that returns values from a temp table. In my
I have a stored procedure that returns two int Values. The first can not
I have created a Stored Procedure, that looks like this: DELIMITER €€ CREATE PROCEDURE
Using SQL Server 2008, I have two stored procedures - create procedure [dbo].[SH_Export_data] (@unit
I have a stored procedure that I call upon using 'core_read' and query method.
I have to use stored procedures to fetch and page data. This particular stored
I have a stored procedure that loops through a table and it may insert
I have a strange, sporadic issue. I have stored procedure that returns back 5

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.