Does SQL Table Column is assigned with column number

Sarvesh Pandey 141 Reputation points
2020-12-03T12:49:37.227+00:00

In Table, we can see there is number assigned automatically (line number) is the same thing is available for the columns (column number) and how can we get that number?
I need a SQL query to find the column number not the number of columns.

Developer technologies | Transact-SQL
{count} vote

6 answers

Sort by: Most helpful
  1. Erland Sommarskog 121.8K Reputation points MVP Volunteer Moderator
    2020-12-07T22:23:34.757+00:00

    This query is working but i need to define table name and column name. My requirement is the query should automatically detects the table and column name.

    Your requirement is still unclear, but I like to point out that an SQL query always refers to a fixed of tables and columns. An SQL query as such is never dynamic.

    But you can build queries dynamically by means of string manipulation, and possibly by reading metadata tables. String manipulation can be done in any language, including T-SQL, but there are language that are equipped for the task.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.