Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:23:16+00:00 2026-06-11T08:23:16+00:00

I am developing a web application (using classic asp for now) that needs to

  • 0

I am developing a web application (using classic asp for now) that needs to query two tables on two separate databases on the same server.

I have been given separate application-level login/passwords for each database by the IT team which will be used in my code to connect.

I want to create a query that links two tables (one from each database) together, but not too sure how, and Google hasn’t helped me much either.

I’m assuming I have to create two connections to do this as I have two separate logins, but how then would I create a query that uses tables from each.

Just a note – our IT team will not at this stage link the two databases together. I’m pretty much stuck with what I have.

Hope you can help.
Mat

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:23:18+00:00Added an answer on June 11, 2026 at 8:23 am

    The typical syntax for a cross database query would be something like:

    SELECT <columns>
      FROM [schema].[table] t1 INNER JOIN
           [databaseName].[schema].[table] t2 ON <condition>
    

    However, if you’re using 2005 or above, it’s well worth creating a synonym in the first database so that the reference to the second database isn’t peppered throughout your code (what if the database name changes later)?

    CREATE SYNONYM [schema].[synonymName] FOR [databaseName].[schema].[table]
    

    Then your query becomes:

    SELECT <columns>
      FROM [schema].[table] t1 INNER JOIN
           [schema].[synonymName] t2 ON <condition>
    

    You may need to set permissions appropriately such that the user you are using to connect to the first database has access to the second. If the IT team simply grants the relevant access to both databases from the same server principal, that is the best way to achieve it. If you are stuck with having two totally separate logins then that sucks. But there isn’t any need to ‘link the databases together’ in order to run a cross-database query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a web application using ASP .NET MVC 1.0 and jQuery (including the
I am developing an ASP.Net MVC 3 Web application using Razor Views. I have
I am developing web application using asp.net, but i want to work on asp
I'm developing a web application using asp.net. There is a text box which contains
I'm developing a web application using asp.net Mvc 2 and NHibernate, and I'm paging
I'm developing an web application using asp.net mvc, and i need to do a
I am developing a web application using asp.net mvc... I am listing out the
We are developing a web application using asp.net and sql server. We are required
I am developing a web application using Asp.net mvc framework with concept of sub
I'm developing a web application using ASP.NET MVC (I'm new to the framework and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.