Solved

Join on a open rowset

Posted on 2008-10-03
3
318 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
ID: 22633360
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
ID: 22633400
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
ID: 31502729
Thanks for your help!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

778 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