NEXT_DATABASE Function [System]

Returns the next database ID number, or the first database if the parameter is NULL.

Syntax

NEXT_DATABASE ( { NULL | database-id } )
Note: CIS functional compensation performance considerations apply.

Parameters

Parameter

Description

database-id

An integer that specifies the ID number of the database.

Returns

INT

Examples

The following statement returns the value 0, the first database value:

SELECT NEXT_DATABASE( NULL ) FROM iq_dummy

The following statement returns NULL, indicating that there are no more databases on the server:

SELECT NEXT_DATABASE( 0 ) FROM iq_dummy

Usage

You can use NEXT_DATABASE to enumerate the databases running on a database server. To get the first database, pass NULL; to get each subsequent database, pass the previous return value. The function returns NULL when there are no more databases.

Standards and Compatibility

  • SQL—Transact-SQL extension to ISO/ANSI SQL grammar.

  • Sybase—Not supported by Adaptive Server Enterprise.

Related reference
COL_NAME Function [System]
DB_ID Function [System]
DB_NAME Function [System]
DB_PROPERTY Function [System]
OBJECT_ID Function [System]
OBJECT_NAME Function [System]