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)
 dynamic ORDER BY clause in embedded SQL

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-04-08 : 11:53:00
patty writes "I just wrote a short time ago about using a variable in an ORDER BY clause and I didn't mention that it is embedded SQL which may make a difference. I am assigning a string variable with the table name and column name and then using the variable in the Order By as follows:

string ls_mod
ls_mod = "dbo.DHTFOSCH.CREW" (different table name and column name depending on which radio button is selected)

DECLARE lcur_daily_emergency CURSOR FOR
SELECT yada
FROM yada
WHERE yada
ORDER BY :ls_mod
USING istr_report.database;

ls_mod does have the correct value in it, but the order by is not working. Please help. Thanks."
   

- Advertisement -