SQL Flow Field Guide

USE

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

switches the current database

What changes

Input
none
Output or change
database context of the session

Syntax at a glance

USE { database_name } [ ; ]

Work example

A script must change its database context before resolving an unqualified object name.

Confirm the target database from the connection and script header. Keep context changes out of shared production sessions.

Check your work USE. The current database is the intended one before the next statement runs.

Open Microsoft Learn for full syntax, permissions, and details for your version.