Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Union Queries - Referencing The Names Of The Source Table

Status
Not open for further replies.

DataChick

IS-IT--Management
Apr 17, 2002
108
US
Is it possible to create a field that shows the name of the source table in a Union query?

I am creating a union query to combine many source tables and I need to be able to easily reference which source table the particular data came from. Does anyone know if there is a way to pull in the table name in the query results?

Thank you in advance for your help.

"The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents."
-Nathaniel Borenstein
 
just hardcode it
Code:
select foo
     , bar
     , 'table1' as source_table
  from table1
union all
select qux
     , fap
     , 'table2' 
  from table2


r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top