I'm trying to get a list of distinct values from a column that is in every table. Obviously, I could do them one at a time, but I'm hoping to create a SQL Agent job and put the results in a table.
select distinct ClassID from dbo.Table1, Table2, and so on.
The output should have the name of the table and the distinct ClassID value. There are approximately 500 tables in the database. I've been asking Herr Google, but I can't seem to find what I'm looking for.
It should look some thing like this:
Table Name ClassID
Table 1 12345