Solved

Join on a open rowset

Posted on 2008-10-03
3
316 Views
Last Modified: 2012-05-05
hi there,
I have a query that need to be join with another query that comes from another database. I have an open rowset and it works how can i achieve this?
here the open rowset:
SELECT a.*
FROM OPENROWSET('SQLOLEDB','GIS';'gisinq';'gisinq',
   'SELECT FOLIO, [NAME] FROM gis.PARCELS_HOMEOWNERS_ASSOCIATIONS ORDER BY [NAME]') AS a

and need to be link with this query:
SELECT DISTINCT uvw_PV_LOOKUP.NUMBER_KEY, uvw_PV_LOOKUP.ENTERED_DATE, tblAddressLookup.NAME_LINE_1,
       tblAddressLookup.NAME_LINE_2, tblAddressLookup.MAILING_ADDRESS, tblAddressLookup.MAILING_ADDRESS_2,
      tblAddressLookup.SITUS_ADDRESS
FROM uvw_PV_LOOKUP left outer join tblAddressLookup
            on uvw_PV_LOOKUP.folio_NUMBER = tblAddressLookup.FOLIO_NUMBER
            left outer join --Here
where
      uvw_PV_LOOKUP.DATA_STATUS ='APPLIED'AND
      uvw_PV_LOOKUP.TYPE_DEPT = 'BUILDING' AND

How can i do this?
0
Comment
Question by:jsctechy
  • 2
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
this should do:
SELECT DISTINCT uvw_PV_LOOKUP.NUMBER_KEY, uvw_PV_LOOKUP.ENTERED_DATE, tblAddressLookup.NAME_LINE_1,
       tblAddressLookup.NAME_LINE_2, tblAddressLookup.MAILING_ADDRESS, tblAddressLookup.MAILING_ADDRESS_2,
      tblAddressLookup.SITUS_ADDRESS, a.NAME
FROM uvw_PV_LOOKUP left outer join tblAddressLookup
            on uvw_PV_LOOKUP.folio_NUMBER = tblAddressLookup.FOLIO_NUMBER
            left outer join OPENROWSET('SQLOLEDB','GIS';'gisinq';'gisinq',
   'SELECT FOLIO, [NAME] FROM gis.PARCELS_HOMEOWNERS_ASSOCIATIONS ORDER BY [NAME]') AS a
  ON a.FOLIO = uvw_PV_LOOKUP.folio_NUMBER 
where
      uvw_PV_LOOKUP.DATA_STATUS ='APPLIED'AND
      uvw_PV_LOOKUP.TYPE_DEPT = 'BUILDING' AND

Open in new window

0
 
LVL 1

Author Comment

by:jsctechy
Comment Utility
did you know i have that? i was missing the part ON a.FOLIO = uvw_PV_LOOKUP.folio_NUMBER  and it was giving me an error.

I guess i overlooked the query. too early in the morning i guess!
Thanks,
jsctechy
0
 
LVL 1

Author Closing Comment

by:jsctechy
Comment Utility
Thanks for your help!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
C# Application Local DB Connection String 23 57
Copy Database Wizard Error 3 19
sql calculate averages 18 21
Azure SQL DB? 3 12
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now