sys.sysdatabases (Transact-SQL)

Contains one row for each database in an instance of Microsoft SQL Server. When SQL Server is first installed, sysdatabases contains entries for the master, model, msdb, and tempdb databases.

Important

This SQL Server 2000 system table is included as a view for backward compatibility. We recommend that you use the current SQL Server system views instead. To find the equivalent system view or views, see Mapping SQL Server 2000 System Tables to SQL Server 2005 System Views. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

Column name

Data type

Description

name

sysname

Database name

dbid

smallint

Database ID

sid

varbinary(85)

System ID of the database creator

mode

smallint

Used internally for locking a database while it is being created.

status

int

Status bits, some of which can be set by using ALTER DATABASE as noted:

1 = autoclose (ALTER DATABASE)

4 = select into/bulkcopy (ALTER DATABASE using SET RECOVERY)

8 = trunc. log on chkpt (ALTER DATABASE using SET RECOVERY)

16 = torn page detection (ALTER DATABASE)

32 = loading

64 = pre recovery

128 = recovering

256 = not recovered

512 = offline (ALTER DATABASE)

1024 = read only (ALTER DATABASE)

2048 = dbo use only (ALTER DATABASE using SET RESTRICTED_USER)

4096 = single user (ALTER DATABASE)

32768 = emergency mode

65536 = CHECKSUM (ALTER DATABASE)

4194304 = autoshrink (ALTER DATABASE)

1073741824 = cleanly shutdown

Multiple bits can be ON at the same time.

status2

int

16384 = ANSI null default (ALTER DATABASE)

65536 = concat null yields null (ALTER DATABASE)

131072 = recursive triggers (ALTER DATABASE)

1048576 = default to local cursor (ALTER DATABASE)

8388608 = quoted identifier (ALTER DATABASE)

33554432 = cursor close on commit (ALTER DATABASE)

67108864 = ANSI nulls (ALTER DATABASE)

268435456 = ANSI warnings (ALTER DATABASE)

536870912 = full text enabled (set by using sp_fulltext_database)

crdate

datetime

Creation date

reserved

datetime

Reserved for future use.

category

int

Contains a bitmap of information used for replication:

1 = Published for snapshot or transactional replication.

2 = Subscribed to a snapshot or transactional publication.

4 = Published for merge replication.

8 = Subscribed to a merge publication.

16 = Distribution database.

cmptlevel

tinyint

Compatibility level for the database. For more information, see ALTER DATABASE Compatibility Level (Transact-SQL).

filename

nvarchar(260)

Operating-system path and name for the primary file for the database.

filename is visible to dbcreator, sysadmin, the database owner with CREATE ANY DATABASE permissions, or grantees that have any one of the following permissions: ALTER ANY DATABASE, CREATE ANY DATABASE, VIEW ANY DEFINITION. To return the path and file name, query the sys.sysfiles compatibility view, or the sys.database_files view.

version

smallint

Internal version number of the SQL Server code with which the database was created. Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.

See Also

Reference

ALTER DATABASE (Transact-SQL)

Mapping System Tables to System Views (Transact-SQL)

Compatibility Views (Transact-SQL)