Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How do you change the order by direction with an input variable.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-19 : 00:06:19
Sean writes "I could not get the stored procedure to use a variable as the order by direction. I had to create two stored procedures to accomplish the task and then decide which one to call from the calling function. It seems that it would be much simpler and cleaner if the stored procedure was passed a value and that value was used to determine the direction of the order by.

Here is the procedure for descending the ascending just removes the desc in the name and the end.

CREATE PROCEDURE get_labelname_from_label_desc AS
SELECT label_name
FROM label
ORDER BY label_name DESC"
   

- Advertisement -