Returns the number of columns specified in a Transact-SQL SELECT statement's ORDER BY clause.
INT dbnumorders ( PDBPROCESS dbproc );
where
The number of ORDER BY columns. If there is no ORDER BY clause, dbnumorders returns 0. If there is an error, dbnumorders returns -1.
Once a SELECT statement has been executed and dbresults has been called to process it, you can call dbnumorders to find out how many columns were specified in the current statement's ORDER BY clause. Call dbnumorders after dbresults has returned SUCCEED.