简体   繁体   中英

SQL Server : select from a table with paging, dynamic column sorting, and dynamic column filter

I have a table Person with 3 columns Id , FirstName and LastName .

Is it possible to create a stored procedure that contains paging, a dynamic sort columns, and a dynamic filter columns without composing the SQL query with a string and then executing it ( sp_executesql )?

Params were:

page, pageSize, sortColumn, sortOrder, filterColumn, filterSearchString

It's possible. You can decide that task without dynamic sql. Try to use such params as id_filter_value, id_sort_value, firstname_filter_value, firstname_sort_value, lastname_filter_value, lastname_sort_value instead of sortColumn, sortOrder, filterColumn, filterSearchString and id_start, id_finish instead of page, pageSize

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM