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
 Help Help New qith SQL

Author  Topic 

sammusa
Starting Member

1 Post

Posted - 2005-09-30 : 17:27:48
Hi

I am new to SQL and I have a unique need

I have 2 DB on the same machine DB 1 is called Test1 and DB 2 is called Test2

I want to be able to write one query to compare 2 tables from each of the Databases.

I wrote the first query ie,
use Test
SELECT Unit_Identifier,Piece_Id,Piece_Count
FROM Piece_Unit
where Version_Date = '01/01/2005' order BY Piece_Id

and I get the result from the Piece_unit Table

I wrote another query ie
use Test1
SELECT Piece_Id,PieceName,Inserts
from PalletDetails
WHERE VersionDate = '01/01/2005' ORDER BY Piece_Id


and I get the result from the PalletDetails table


The piece_id of both Tables are same value

I want to combine both queries to a single query and ONLY list the difference from both Tables in reference to the piece_id ( Only list piece_id) that exist on either table only


Thanks




nathans
Aged Yak Warrior

938 Posts

Posted - 2005-09-30 : 18:05:35
Check out Jeff's article here:

http://weblogs.sqlteam.com/jeffs/archive/2004/11/10/2737.aspx



Nathan Skerl
Go to Top of Page
   

- Advertisement -