select id from [@db1]..MyTable t1 INNER JOIN [@db2]..MyTable t2 on [t1].id=[t2].id
but clearly SQL Server doesn't like the database names in variables - how can I achieve what I am trying to do?
I'm on but I'd like it as generic as possible for versions:
Microsoft SQL Server 2012 - 11.0.5058.0 (X64)
May 14 2014 18:34:29
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: )
In this article, we will show how to detach and attach a database and then show how to repair a corrupt database and attach it, If it has some errors. We will show how to detach and attach using SSMS or using T-SQL sentences.