Icon USE

Opens a new database or closes the existing database.

Syntax
USE [<DatabaseName>]

Usage
Use this statement in a script or job definition to open a new database or close a database that was previously opened. To open a new database, specify the database name after the USE keyword. Opening a new database automatically closes the current database that is open. To close the current database and not open a new database, leave the database name blank. This reverts the current database back to the default database, which is always the system-defined Configuration database for jobs.

Examples
-- This job optimizes the Inventory
-- table in the ShopFloor database.

CREATE JOB OptimizeInventory
RUN AS "System"
FROM DATE '2000-01-01' TO DATE '2030-12-31'
WEEKLY
ON SUN
BETWEEN TIME '03:00' AND TIME '04:00'
CATEGORY ''
BEGIN
   USE ShopFloor;
   EXECUTE IMMEDIATE 'OPTIMIZE TABLE Inventory';
   USE;
END

-- Here's the same thing as a script instead

SCRIPT
BEGIN
   USE ShopFloor;
   EXECUTE IMMEDIATE 'OPTIMIZE TABLE Inventory';
   USE;
END

SQL 2003 Standard Deviations
This statement deviates from the SQL 2003 standard in the following ways:

DeviationDetails
ExtensionThis SQL statement is an ElevateDB extension.
Image