I am trying to do a sql script to retrieve info from a main table and join them with data from a table in another database (Same server). The hard part is that for each row in the "main" table, the data that I have to join is in a different database.
I am not sure how I would proceed to do that, I think the only way would be to do some kind of loop. Am I right?
Here is how my two tables look like:
Main table:
main_id
database_name
other tables:
other_id
other_name
I'd like the result to be something like:
main_id
database_name
other_name
Edit: I am trying to write a stored procedure