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
 Compare query?

Author  Topic 

mflammia
Starting Member

44 Posts

Posted - 2008-08-06 : 05:14:46
Trying to write a query to compare a linked DB and a local DB.

This query returns the column ListingTitle form my linked server

select * from openquery (TTDNY1,'Select listingTitle from listings')

This query returns everything from my local database

Select * from realessex.dbo._DATA

The idea is to return everything from the local database that match’s its _name column to the ListingTitle column in the linked server.

Being a pure newbie writing simple queries is about my limit, so would really appreciate the help.

Many thanks.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-06 : 05:23:32
Select t1.* from realessex.dbo._DATA as t1 inner join
(
select * from openquery (TTDNY1,'Select listingTitle from listings')
) as t2 on t1.name=t2.listingTitle


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mflammia
Starting Member

44 Posts

Posted - 2008-08-06 : 05:32:36
Wonderful! Thank you.
Go to Top of Page

mflammia
Starting Member

44 Posts

Posted - 2008-10-07 : 10:46:16
Am trying to display everything from the realessex.dbo_DATA that has not been matched against TTDNY1 listingtitles, my first thoughts are to change the equal = to a not equal <>, but that does not give the desired results.

That makes sense to me to do that, any ideas why that is not working?

Thanks.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-07 : 10:49:23
Select t1.* from realessex.dbo._DATA as t1 left join
(
select * from openquery (TTDNY1,'Select listingTitle from listings')
) as t2 on t2.listingTitle is null

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mflammia
Starting Member

44 Posts

Posted - 2008-10-07 : 10:53:16
Great! Thanks.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-07 : 10:55:36
quote:
Originally posted by mflammia

Great! Thanks.


You are welcome

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -