SqlOrderCol%

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.

Syntax

SqlOrderCol% ( sqlconn%, order% )

where

sqlconn%
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.
order%
Is the number that identifies a particular ORDER BY column. The first column named in the ORDER BY clause is number 1.

Returns

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.

Remarks

Call SqlOrderCol% after SqlResults% has returned SUCCEED.

Example

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

See Also

SqlNumOrders%