[Solved] How can I get the index number of any column in an SQL database?


Most, but not all (I think Oracle is one which doesn’t) database systems implemented the INFORMATION_SCHEMA which you can query to get information about database objects. In order to get the ordinal position of a column in a table, you can use:

SELECT      C.ORDINAL_POSITION
FROM        INFORMATION_SCHEMA.COLUMNS AS C
WHERE       C.TABLE_NAME = 'Table'
        AND C.COLUMN_NAME = 'Password'

I can’t help wonder why you need this information though…

1

solved How can I get the index number of any column in an SQL database?