Syntax for dbcc checkalloc with the fix Option

This section explains only dbcc checkalloc with the fix option. Refer to “dbcc” in the Reference Manual for information about dbcc and its other keywords and options.

Function

dbcc checkalloc with the fix option detects and fixes allocation errors in databases.

Syntax

dbcc checkalloc(database_name, fix)

Example

1> sp_dboption database_name, single, true
2> go

1> use database database_name 
2> go

1> checkpoint 
2> go

1> dbcc checkalloc(database_name, fix)
2> go

1> use master
2> go

1> sp_dboption database_name, single, false
2> go

1> use database_name
2> go

1> checkpoint
2> go

Comments

Databases must be in single-user mode or dbcc checkalloc with the fix option will fail with error 2595.