Table of Contents

Class CompatibilitySchema.Database

Namespace
LinqToDB.Tools.DataProvider.SqlServer.Schemas
Assembly
linq2db.Tools.dll

sys.sysdatabases (Transact-SQL)

Applies to: √ SQL Server (all supported versions) √ Azure SQL Managed Instance √ Azure Synapse Analytics √ Analytics Platform System (PDW)

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 System Tables to System Views (Transact-SQL). 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.


See sys.sysdatabases.

[Table(Schema = "sys", Name = "sysdatabases", IsView = true)]
public class CompatibilitySchema.Database
Inheritance
CompatibilitySchema.Database
Extension Methods

Properties

Category

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.

[Column("category")]
[Nullable]
public int? Category { get; set; }

Property Value

int?

CompatibilityLevel

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

[Column("cmptlevel")]
[NotNull]
public byte CompatibilityLevel { get; set; }

Property Value

byte

Crdate

Creation date

[Column("crdate")]
[NotNull]
public DateTime Crdate { get; set; }

Property Value

DateTime

DbID

Database ID

[Column("dbid")]
[Nullable]
public short? DbID { get; set; }

Property Value

short?

FileName

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.

[Column("filename")]
[Nullable]
public string? FileName { get; set; }

Property Value

string

Mode

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

[Column("mode")]
[Nullable]
public short? Mode { get; set; }

Property Value

short?

Name

Database name

[Column("name")]
[Nullable]
public string? Name { get; set; }

Property Value

string

Reserved

Reserved for future use.

[Column("reserved")]
[Nullable]
public DateTime? Reserved { get; set; }

Property Value

DateTime?

SID

System ID of the database creator

[Column("sid")]
[Nullable]
public byte[]? SID { get; set; }

Property Value

byte[]

Status

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.

[Column("status")]
[Nullable]
public int? Status { get; set; }

Property Value

int?

Status2

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)

[Column("status2")]
[Nullable]
public int? Status2 { get; set; }

Property Value

int?

Version

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.

[Column("version")]
[Nullable]
public short? Version { get; set; }

Property Value

short?