There is another (not necessarily beautiful) alternative:
IF (@source_database = 'wibble') USE wibble; ELSE IF (@source_database = 'wibble2') USE wibble2; ELSE RAISERROR(....) SELECT * FROM dbo.myTable
If you have a real number of databases, this can be tedious. But this is an option nonetheless.
Adathedev
source share