I have a database with a number of tables, I want to return the values of the first column in each table.
To illustrate, if there are, say, 3 tables in the database MyDB called Table1, Table2, Table3 with columns as follows:
Table1 has columns LastName, FirstName, Title
Table2 has columns Street, City, Country
Table3 has columns Age, Ethnicity, Gender, AccommodationType
Then I want the equivalent of doing:
Select LastName from Table1
Select Street from Table2
Select Age from Table3
Of course, in the real database there are about fifty tables and each has its own ideosyncrasies and column names are different in each and of differing types. Can I automate this using schema objects like 'Column_Name' etc in a loop of some sort for each table in the DB?