I have a stored proc that accesses another SQL database thus: " + @sDatabase + ".dbo.tablenamehere. This works fine for most cases but when I try to use this with a join from an empty table, SQL requires that I provide the database name. I need to work around this because the stored proc is kept in source safe to be applied to 3 different databases (development, testing, production).