Click here to Skip to main content
16,018,458 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Actually I want to access a particular Field and I want to get ROW number of a particular Column in our database
Please give me the Answer

What I have tried:

Select ROW_Number() Over(Name) from Student
Posted
Updated 28-Sep-17 19:30pm
v2
Comments
Satyanand Bhardwaj 28-Sep-17 8:22am    
Actually sir i want get Index number of a column like-
Select Indexnumber(Name) from Student

i want to get index number of Name...

I do not think you can directly do that in any valid SQL query and actually get a valid response — because column-indexes can easily change due to the way that a table is defined — without applying a hack around it. Also, it doesn't make any sense, why not the column_name?

For the SELECT statement, you need to either pass the column names or the wildcard. Once the data has been returned, you can read the column by index. That can be done through any SQL reader, such as C# objects for the SQL Server or other similar for MySQL.

But before that, I don't think that is possible. Only a few of the areas permit you to use an ordinal value or the column; ORDER BY clause etc.

There is a similar question on CodeProject you might want to try that, [Solved] SELECT columns by column-index NOT by columnname![^]
 
Share this answer
 
SELECT      C.ORDINAL_POSITION
FROM        INFORMATION_SCHEMA.COLUMNS AS C
WHERE       C.TABLE_NAME = 'TableName'
        AND C.COLUMN_NAME = 'Password'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900