Returns the number of the column that appears in a specified location within the ORDER BY clause of the most recently executed Transact-SQL SELECT statement.
SqlOrderCol% ( sqlconn%, order% )
where
The column number (based on the column's position in the select list) for the column in a specified place in the ORDER BY clause. If order% is invalid, -1 is returned.
Call SqlOrderCol% after SqlResults% has returned SUCCEED.
In the following Transact-SQL statement, SqlOrderCol% with an order% parameter of 1 returns 3, since the first column named in the ORDER BY clause refers to the third column in the SELECT clause:
SELECT dept, name, salary FROM employee ORDER BY salary, name