Navigation:  Key Concepts > Management Topics > SQL TIPS >

Repair SQL Databases

Previous pageReturn to chapter overviewNext page
Show/Hide Hidden Text

If verification of inventory files takes an excessively long time consider repairing your SQL Databases.

Sometimes SQL Databases can become corrupted because of computer problems.  If you attempt to make a backup, for example, you could be warned that there is corruption.

To repair SQL Databases, run Microsoft SQL Server Management Studio Express.

STEP 1  Change State: Restrict Access from Multi_User to Single.  (This will prevent others from inadvertently accessing the database.)

1)  Right-mouse-click on the database name.

2)  Choose Properties (example)

SQLProperties

3)  Go to Options

4)  Scroll to the bottom of the list

5)  Change the default of State: Restrict Access: from Multi_User to Single_User

6)  Choose OK.  Answer YES to close all other connections.

RepairSQLDatabasesSETUP

 

STEP 2  Perform the Repairs

1)  highlight your database

2)  Right-mouse-click and choose New Query

3)  enter DBCC CheckDB in the query box

4)  choose Execute

SQLRepair

5)  when completed, the results will be displayed at the bottom of the screen.  Any tables with problems will be displayed in RED.

 

IF ERRORS ARE FOUND

Then enter the following query to fix the problems databases

DBCC CHECKDB ('YOURDATABASE',REPAIR_ALLOW_DATA_LOSS)

This will then repair the corruptions.

 

STEP 3  Change State: Restrict Access from Single back to Multi_User.  (This will allow others to access the database.)

1)  Right-mouse-click on the database name.

2)  Choose Properties

3)  Go to Options

4)  Scroll to the bottom of the list

5)  Change the default of State: Restrict Access: from Single_User to Multi_User

6)  Choose OK.  Answer YES to close all other connections.

How Often?

You can run this routine regularly to make sure that no corruption is present.