Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 storing intermediate steps?

Author  Topic 

max_tm
Starting Member

4 Posts

Posted - 2008-10-07 : 11:40:14
Sorry, I know this information is definitely available online or has already been posted in the forum, but since I don't know the SQL vocabulary I'm useless at trying to find it.

I'd like to be able to take the intersection of two tables, and refer to the result as if it were a stored table in my database, is there a way to do this?

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-10-07 : 11:51:39
I'm not 100% sure I understand what you want to do exactly. But, you could store the results in a temp table or table variable to use later. For example:
SELECT 
*
INTO
#MyTempTable
FROM
(
SELECT *
FROM Table1

INTERSECT

SELECT *
FROM Table2
) AS T

SELECT *
FROM #MyTempTable
Go to Top of Page

max_tm
Starting Member

4 Posts

Posted - 2008-10-07 : 13:10:03
Exactly what I was looking for. Thanks!
Go to Top of Page
   

- Advertisement -