Click here to Skip to main content
14,733,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Want to send ASC and DESC as a parameter to sql procedure from


select * from item order by id desc

here how to send desc from

1 solution

There are two ways to do it.
1. Send a parameter to the Stored Procedure and write two separate SELECT statements based on the parameter passed. (use a IF statement)
2. Construct a dynamic query and execute it using the EXEC statement.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900