Home > Articles

  • Print
  • + Share This
This chapter is from the book

Selecting a Database

As you’ve just seen, when you first connect to SQL Server, a default database is opened for you. This is usually a database named master (which as a rule you should never play with). Before you perform any database operations, you need to select the appropriate database. You did this using the drop-down box in the toolbar, but you can also select the database using the SQL USE keyword.

For example, to use the learnsql database, you would enter the following (in a query window) and execute it:

Input common.jpg

USE learnsql;

Output common.jpg

Command(s) completed successfully.

Analysis common.jpg

The USE statement does not return any results, but you will see a message confirming that the command was successfully completed.

Remember, you must always USE a database before you can access any data in it.

  • + Share This
  • 🔖 Save To Your Account