use

Description

Specifies the database with which you want to work.

Syntax

use database_name 

Parameters

database_name

is the name of the database to open.

Examples

Example 1

use pubs2 
go

The current database is now pubs2.

Usage

Standards

SQL92 – Compliance level: Transact-SQL extension.

Permissions

If the database has a “guest” account, all users can use the database. If the database does not have a “guest” account, you must be a valid user in the database, have an alias in the database, or be a System Administrator or System Security Officer.

See also

Commandscreate database, drop database

System proceduressp_addalias, sp_adduser, sp_modifylogin