Displays the number of free pages in the specified disk piece.
curunreservedpgs (dbid, lstart, unreservedpgs)
is the ID for a database. These are stored in the db_id column of sysdatabases.
is a page within the disk piece for which pages are to be returned.
is the default value to return if the dbtable is presently unavailable for the requested database.
Returns the database name, device name, and the number of unreserved pages for each device fragment
If a database is open, curunreservedpgs takes the value from memory. If it is not in use, the value is taken from the third parameter you specify in curunreservedpgs. In this example, the value comes from the unreservedpgs column in the sysusages table.
select
(dbid), d.name, curunreservedpgs(dbid, lstart, unreservedpgs) from sysusages u, sysdevices d where u.vdevno=d.vdevno and d.status &2 = 2
name ------------------------------ -------------------------- ----------- master master 1634 tempdb master 423 model master 423 pubs2 master 72 sybsystemdb master 399 sybsystemprocs master 6577 sybsyntax master 359 (7 rows affected)
Displays the number of free pages on the segment for dbid starting on sysusages.lstart:
select curunreservedpgs (dbid, sysusages.lstart, 0)
curunreservedpgs, a system function, returns the number of free pages in a disk piece.
If a database is open, the value returned by curunreservedpgs is taken from memory. If it is not in use, the value is taken from the third parameter you specify in curunreservedpgs.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute curunreservedpgs.