all groups > sql server programming > november 2007 >
You're in the

sql server programming

group:

How to use dynamic Order By Clause in a stored procedure?


How to use dynamic Order By Clause in a stored procedure? Andrew
11/3/2007 7:56:01 AM
sql server programming:
Hello, friends,

We are using C#.net and SQL Server 2000, and using stored procedures to
retrieve records. However, with a new feature we are developing now, we need
to sort the records based on user's selections.

So, the Order By clause will be dynamic. Is there a way that a stored
procedure will accept those dynamic Order By clause, say, something like

Order By @orderByCondtion,

where @orderByCondtion is the passed in parameter.

AddThis Social Bookmark Button