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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Cross-reference 2 databases

Author  Topic 

SpeshulK926
Starting Member

16 Posts

Posted - 2007-06-21 : 14:15:42
I need to do a cross reference on 2 different databases for first/lastnames. I'm really not sure how to do this... I usually only have to do small simple queries, but I need to get this done for my boss... can someone help me?

I need to pull all data where:
Database1.Table.Firstname = Database2.Table.Firstname AND Database1.Table.LastName = Database2.Table.Lastname...

Any help would be appreciated... I would write more, but I don't even know how to construct that kind of query. Oh yeah, and I'm a server admin, so rights isn't an issue.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-06-21 : 14:17:20
SELECT *
FROM Database1..Table t1
INNER JOIN Database2..Table t2
ON t1.FirstName = t2.FirstName AND t1.LastName = t2.LastName

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -