sp_setsuspect_granularity

Description

Displays or sets the recovery fault isolation mode for a user database, which governs how recovery behaves when it detects data corruption.

Syntax

sp_setsuspect_granularity [dbname 
	[, "database" | "page" [, "read_only"]]]

Parameters

dbname

is the name of the database for which to display or set the recovery fault isolation mode. For displaying, the default is the current database. For setting, you must be in the master database and specify the target dbname.

database

marks the entire database suspect, which makes it inaccessible, if the recovery process detects that any of its data is suspect.

page

marks only the corrupt pages suspect, making them inaccessible, if recovery detects corrupt data in the database. The rest of the data is accessible.

read_only

if specified, marks the entire database read only if recovery marks any pages suspect.

Examples

Example 1

Displays the recovery fault isolation mode for the current database:

sp_setsuspect_granularity
DB Name  Cur. Suspect Gran.  Cfg. Suspect Gran.  Online mode
-------  ------------------  ------------------  -----------
pubs2    database           database           read/write

Example 2

Displays the current and configured recovery fault isolation mode for the pubs2 database:

sp_setsuspect_granularity pubs2

Example 3

The next time recovery runs in the pubs2 database, if any corrupt pages are detected, only the suspect pages will be taken offline and the rest of the database will be brought online:

sp_setsuspect_granularity pubs2, "page"
DB Name       Cur. Suspect Gran. Cfg. Suspect Gran.
------------- ------------------ -----------------
pubs2          database             database
sp_setsuspect_granularity: The new values will become effective
    during the next recovery of the database ’pubs2’.

Example 4

The next time recovery runs in the pubs2 database, if any corrupt pages are detected, only the suspect pages will be taken offline and the rest of the database will be brought online in read only mode:

sp_setsuspect_granularity pubs2, "page", "read_only"

Example 5

The next time recovery runs in the pubs2 database, if any corrupt data is detected, the entire database will be marked suspect and taken offline:

sp_setsuspect_granularity pubs2, "database"

Usage

Permissions

The permission checks for sp_setsuspect_granularity differ based on your granular permissions settings.

Granular permissions enabled

With granular permissions enabled, you must be a user with own database privilege on the specified database to set the recovery fault isolation mode.

Any user can execute sp_setsuspect_granularity to display settings.

Granular permissions disabled

With granular permissions disabled, you must be a user with sa_role to set the recovery fault isolation mode.

Any user can execute sp_setsuspect_granularity to display settings.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

Event

Audit option

Command or access audited

Information in extrainfo

38

exec_procedure

Execution of a procedure

  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect

See also

Commands dump database, dump transaction, load database

System procedures sp_dboption, sp_forceonline_db, sp_forceonline_page, sp_listsuspect_db, sp_listsuspect_page, sp_setsuspect_threshold