curunreservedpgs

Description

Returns the number of free pages in the specified disk piece.

Syntax

curunreservedpgs(dbid, lstart, unreservedpgs)

Parameters

dbid

is the ID for a database. These are stored in the db_id column of sysdatabases.

lstart

is a page within the disk piece for which pages are to be returned.

unreservedpgs

is the default value to return if the dbtable is presently unavailable for the requested database.

Examples

Example 1

Returns the database name, device name, and the number of unreserved pages for each device fragment:

select db_name(dbid), d.name,
        curunreservedpgs(dbid, lstart, unreservedpgs)
        from sysusages u, sysdevices d
        where d.low <= u.size + vstart
            and d.high >= u.size + vstart -1
            and d.status &2 = 2

master           master        184
master           master        832 
tempdb           master        464 
tempdb           master       1016 
tempdb           master        768 
model            master        632 
sybsystemprocs    master      1024 
pubs2             master      248 

Example 2

Displays the number of free pages on the segment for dbid starting on sysusages.lstart:

select curunreservedpgs (dbid, sysusages.lstart, 0)

Usage

Standards

SQL92 – Compliance level: Transact-SQL extension.

Permissions

Any user can execute curunreservedpgs.

See also

Functions db_id, lct_admin