0

I have this Classic ASP application running with SQL Server. I use the following query:

sql = "SELECT TOP 30 r.RMANumber, r.CompanyName, r.ContactName, r.Country, r.Phone, r.IssuanceDate, r.DateReceived, r.CreatedBy " & _
      "FROM rma r " & _
      "WHERE r.IssuanceDate >= '" & startDate & "' AND r.IssuanceDate <= '" & DateAdd("d", 1, CDate(endDate)) & "' AND r.RMAClosed = 'No' " & _
      "ORDER BY IssuanceDate DESC"

I'd like to add an INNER JOIN to it but the INNER JOIN would look in the different database. Can I do this:

sql = "SELECT TOP 30 r.RMANumber, r.CompanyName, r.ContactName, r.Country, r.Phone, r.IssuanceDate, r.DateReceived, r.CreatedBy " & _
     "FROM [database1].[dbo].[rma] r " & _
     "INNER JOIN [database2].[dbo].[users] u " & _
4
  • 3
    Yes. Have you tried it? Commented Jan 27, 2015 at 21:32
  • 4
    Try first, ask questions later. Commented Jan 27, 2015 at 21:34
  • 1
    @Brasciole: Yes, you can. Take a look at this , give it a shot and come back with what you tried and any questions you have. Commented Jan 27, 2015 at 21:49
  • 2
    Yes, as long as the databases are in the same Server... Commented Jan 27, 2015 at 22:31

1 Answer 1

1

If your other database is in another server. Put the IP address of the server as shown below:

sql = "SELECT TOP 30 r.RMANumber, r.CompanyName, r.ContactName, r.Country, r.Phone, r.IssuanceDate, r.DateReceived, r.CreatedBy " & _
      "FROM [database1].[dbo].[rma] r " & _
      "INNER JOIN [ip address of other server here].[database2].[dbo].[users] u " & _

Note: Be sure you're connected and have an access to that server to where your other database resides.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.