• Thanks for the question, Simply Nice 🙂

    (we have like 250+ database on each principals where the structure of each database is same, only the data stored is different, hosted on multiple database server over different regions. I once wrote a query to fetch a specific set of records from one server on all databases and I used this "execute use db1" and the execute the underlying sql statement and then store them in the table variable.. the whole query was awful and then I changed in to one whole batch and then stored it in to the temp table and used the cursor to loop trough the next database and then execute it and then store in result... the complete execution took only 15 seconds to fetch records from all database..like some less than 600 records... I actually came to now here that executing of the "use" statement using "execute" does not changes the physical connection of the current session. memory recall 🙂 )

    ww; Raghu
    --
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.