O'Reilly logo

Microsoft® SQL Server™ 2005: Applied Techniques Step by Step by Solid Quality Learning

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sorting and Filtering Dynamically

If a query returns a large set of records, the results will be more useful if the user can define the order in which the rows are returned and which rows should be filtered out.

Adding a Sort Order to a Dynamic Query

To sort a dynamic query, just append the ORDER BY clause followed by a list of columns in the order indicated by the user. If the user wants to get the information in descending order, also append the DESC keyword.

In the following code, the order selections are stored in a special collection called SortInfo, a custom class designed to store all the information needed for each order selection.

Public Class SortInfo Public SchemaName As String Public TableName As String Public ColumnName As String ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required