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 to use variable in Order by of select statment

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-18 : 00:20:17
James Li writes "Hi, I try to pass in a parameter in stored procedure which it will be used in Order by phase. For example exec sp_SPname @orderByfField.
The Stored Proc. is like this:

create Proc as sp_SPName
(
@orderByField varChar(30)=null
)
as
select * from TBLName where id=1234 order by @orderByField

When exec this proc, it give the error says it cannot use Variable in Order by.
So How can I resolve this problem?

Thanks."
   

- Advertisement -