How to get the original name of columns in SQL queries if aliases are used?
I use %SQL.Statement. The original column names are not contained in the metadata.
Sample query:
SELECT column1->name as name, column2 age FROM sample.table
How to get:
- column1->name
- column2
I can get you column 2:
w stmt.%Metadata.columns.GetAt(2).property.SqlFieldName
but I don't see a way to do this with Implicit JOINS (->). You can get the table and kind of figure it out with something like this:
w stmt.%Metadata.columns.GetAt(2).property.parent.SqlTableName
I think the question here is what are you going for in the bigger picture? Perhaps there's another angle?
Thanks! My task: I get a SQL query from the service and return a list with column names. But it is important that the list contains the original column names.