Greetings all,
I have a very simples question:
I have a query like this: SELECT * FROM Table1 T1 RIGHT JOIN Table2 T2 ON T1.id = T2.id
I then execute a DataReader with this query. In the resulting DataReader I can get the columnnames, types, etc. What I can’t seem to get is the tablename / alias the column belongs to.
What I need
I get something like:
Column1, column2, column3
And I’d like to get something like:
T1.column1, T1.column2, T2.column1, …
What I need is only the schema of the resulting “virtual table” and not the actual values of each row.
What I can do as a “work around”
I can run the same query with “FOR XML AUTO, XMLSCHEMA, ELEMENTS XSINIL” at the end. This gives me the complete schema of the resulting “virtual table” and also a lot more info than I need. But what I get is well organized and I can easily get the name of the table each resulting column belongs to.
Is there an easier way to do this?
Any help will be more than welcome! Thanks!
Best Regards,
Fernando Gomes