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!

How to dump query results into new table based off of parameter fields

Status
Not open for further replies.

renee35

MIS
Jan 30, 2007
199
What I am trying to do is allow the user to return data based off of results being created from a new table. I have 2 tables that I need to join and dump the results into a new table, then join those fields to an existing query. Below is an example of what I am trying to do:

select column1, column2
into newtable
from table1
join table2
where table1.field = @mydb and table2.field = @state

From this point I want to take these results and add it to an existing query as such:

INNER join (
select column1, column2 from newtable
) r on 1=1

Thanks a bunch!!

-T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top