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!

get table name into another table

Status
Not open for further replies.

mgh730

Programmer
Jun 12, 2002
23
US
I'm trying to do an "insert... select" to get data from multiple tables matching certain criteria into a temporary table. I'd then like to order the data in the temporary table, but look at each entry in the table and know what table it came from originally. I was thinking there must be some way to return the table name in the select statement, anyone know if this is possible?
like:
Code:
insert into temptable select date, <find tablename> as originalname from table1;
(what goes in place of <find tablename>?)

thanks
 
Code:
insert into temptable(date,name)
select date, 'table1' 
  from table1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top