Sample Chapter: Wrox Beginning SQL Server 2000 Programming - Chapter 3: Query Analyzer (contd.)
(Page 9 of 10 )
Try It Out – Temporarily Change Databases 1. Ensure that Query Analyzer is running and that you are logged in as RDewson. This equates to the User ID that you installed SQL Server with.

2. From within Query Analyzer, use the Database combo box and select pubs from the dropdown list. This now means that any work within any Query pane in Query Analyzer is done within the pubs database. Recall from earlier in the chapter the mention of the USE command for altering the database? This is performing the same process.

3. To prove that this alteration is only temporary, switch to Enterprise Manager and go to the Logins icon. You will see that nothing has altered and that Northwind is still the Default Database for RDewson:

Using the Database combo box does not run the same line of code that we saw earlier when changing the default database in Query Analyzer. So Query Analyzer just keeps track of the database change under its own hood so that, when you do any work within Query Analyzer, it always knows which database to point to. Then, when Query Analyzer is finished with, it throws away its knowledge of which database it was working on so that, next time it is started, it will revert back to the default database.
Next: Summary >>
More SQL Server Articles
More By Mitchell Harper