Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select from two databases on two instances

Status
Not open for further replies.

griffitd

Programmer
Joined
Aug 20, 2002
Messages
189
Location
GB
Hi

I need a query to select data from two database which are in different instances.

SELECT *
FROM dbo.ShippingInvoices INNER JOIN
dbo.ShippingDeliveries ON dbo.ShippingInvoices.ShippingDeliveryID = dbo.ShippingDeliveries.ShippingDeliveryID INNER JOIN
ukwhdb1.warehousenew.dbo.wad ON dbo.ShippingInvoices.WadNo = ukwhdb1.warehousenew.dbo.wad.WadNo

is this possible

Thanks
 
Yes. This is possible assuming you have a linked server set up. Also, you need to change your query slightly. SQL doesn't like 5 part naming, which you are using in your ON clause. To accommodate this, use table aliases, like this:

Code:
SELECT *
FROM   dbo.ShippingInvoices  As Invoices 
       INNER JOIN dbo.ShippingDeliveries As Deliveries 
          ON Invoices.ShippingDeliveryID = Deliveries.ShippingDeliveryID 
       INNER JOIN ukwhdb1.warehousenew.dbo.wad As [!]wad_alias[/!] 
          ON Invoices.WadNo = [!]wad_alias[/!].WadNo

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top