0

how to link two different database in same SQL Server instance and send queries between them

0

2 Answers 2

5

use like below.

DB1.dbo.TableFromDB1
DB2.dbo.TableFromDB2

DB - database

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

Comments

1

Look at using synonyms "CREATE SYNONYM".

You can access the databases directly with a full path. But, that code will break if the database is ever renamed or changed.

Using a synonym, the code can remain unchanged; when the database moves, just update the synonym.

This can be useful when you have a test and production environment. The code does not have to change just because you move it from test to production and the database names do not have to be identical.

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.