For SQL Server 6.5 information, see sp_dboption in What's New for SQL Server 6.5.
Displays or changes database options.
sp_dboption [dbname, optname, {true | false}]
where
With this option set to true, all user-defined datatypes or columns not explicitly defined as NOT NULL during a CREATE TABLE or ALTER TABLE statement will default to allowing NULLs. Columns defined with constraints will follow constraint rules regardless of this setting (for example, PRIMARY KEY columns, IDENTITY columns, and columns of type bit cannot be NULL).
Session settings override the default database setting for ANSI null default. For more information, see the SET statement.
The no chkpt on recovery option is useful when an up-to-date copy of a database is kept. In these situations, there is a "primary" and a "secondary" database. Initially, the primary database is dumped and loaded into the secondary database. Then, at intervals, the transaction log of the primary database is dumped and loaded into the secondary database. If this option is on (true) in the secondary database, no checkpoint record is added to a database after it is recovered, so subsequent transaction log dumps from the primary database can be loaded into it.
When a database is placed online, all devices belonging to the specified database are opened (if they are not already open) and marked as non-deferred, and the database is recovered and becomes available for use.
When a database is placed offline, all devices belonging to that database are closed and marked as deferred, except those that contain space belonging to other online databases. Databases placed offline are not recovered automatically at server startup.
Note A database cannot be placed offline if it has an active user.
When set to true, this option enables publishing and adds the user repl_subscriber to the database.
When set to false , it disables publishing, drops all publications, unmarks all transactions that were marked for replication in the transaction log, and removes the database user repl_subscriber.
After performing non-logged operations, using the DUMP TRANSACTION statement is prohibited. Issuing DUMP TRANSACTION after making unlogged changes to the database with SELECT INTO or bulk copy produces an error message telling you to use DUMP DATABASE instead. Once all non-logged operations are completed, turn off select into/bulkcopy and issue the DUMP DATABASE statement.
By default, the select into/bulkcopy option is turned off in newly created databases. To change the default situation, set this option in the model database.
Note Because SELECT is a keyword, you must enclose select into/
bulkcopy in quotation marks to avoid a syntax error.
This stored procedure does not subscribe to a database. It permits a database to subscribe to a published database.
To display the list of available database options, execute sp_dboption with no parameters. To list all of the configured options for a particular database, execute the sp_helpdb system stored procedure. The only option you can set for the master database is trunc. log on chkpt. The database owner or system administrator can set or turn off particular database options for all new databases by executing sp_dboption on the model database.
After sp_dboption has been executed, a checkpoint will be executed in the database for which the option was changed. This will cause the change to take effect immediately.
For additional details on database options, see the Microsoft SQL Server Administrator's Companion.
Execute permission to display the list of options only (using sp_dboption with no parameters) defaults to all users. Execute permission to change an option (using sp_dboption with parameters) defaults to the system administrator and the database owner of the database for which the option is to be changed.
This example displays a list of the database options.
sp_dboption go Settable database options: -------------------------- ANSI null default dbo use only no chkpt on recovery offline published read only select into/bulkcopy single user subscribed trunc. log on chkpt.
This example makes the pubs database read only.
sp_dboption pubs, 'read', TRUE go CHECKPOINTing database that was changed.
This example makes the pubs database writable again.
sp_dboption pubs, 'read', FALSE go CHECKPOINTing database that was changed.
This example takes the sales database offline if there are no users accessing the sales database.
USE master go sp_dboption sales, offline, TRUE go CHECKPOINTing database that was changed.
master.dbo.spt_values, master.dbo.sysdatabases
CHECKPOINT | sp_droppublisher |
SELECT | sp_dropsubscriber |
sp_addpublisher | sp_helpdb |
sp_addsubscriber | sp_helpdistributor |
sp_changesubscriber | sp_helpserver |
sp_configure | sp_helpsubscriberinfo |