Search code examples
sql-servervb.netmdf

SQL join Query Between Two Different Database File


I am creating a Windows application which have two SQL Server databases. One is in application/startup path and other is in different drive.

I have two SQL Server database files with different names. Both are in different location. There are same tables in both databases. I want toe create a join query between tables for different database.

So it is possible or not? If yes then how? This is my first question in stack over flow so please help me.


Solution

  • If your databases are on same sql server instances there is no need to create linked servers(because it will hurt performance),you can simply reference table with [DBName].[Schema].[TableName]. If you have same database with 2 files sql will handle that for you If you have 2 instances than you could create linked servers or handle that in applicaiont(join 2 result sets)