Stored Procedure having Sorting, Paging and Filtering


Really nice way to handle Paging, Filtering and Sorting from SQL itself.

Connoisseur

In day to day work we often need data to displayed in Grid that needs sorting, paging and filtering on User Interface whether web or windows. I often struggle to find a unified solution. I found that best way is to have fetch data  in required  format from stored procedure and just have presentation logic on UI  rather than mixing a lot of logic for Sorting, Paging and Filtering.  Here I am presenting a simple approach to have data from Stored procedure in required format based on given parameters.

CREATE PROCEDURE USP_SEL_Contacts
(
        /* Optional Filters for Dynamic Search*/
       @ContactID INT = NULL,
       @FirstName NVARCHAR(50) = NULL,
       @LastName NVARCHAR(50) = NULL,
       @EmailAddress NVARCHAR(50) = NULL,
       @EmailPromotion INT = NULL,
       @Phone NVARCHAR(25) = NULL,
 …

View original post 1,468 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s