🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: dk.edb.database
Article #15228

Re: Suspect database?

#15228
From: JH
Date: Fri, 15 Jun 2001 08:07
188 lines
5071 bytes
> databasen er suspect, 
> Hvad kan jeg g�re for at f� den op og k�re igen? 

copy&paste.......

What causes a suspect database? How can I fix this?
A database can become suspect if one of these conditions is true: 
- If one or more database files are not available. 
- If the entire database is not available. 
- If one or more database files are corrupted. 
- If a database resource is being held by the operating system. 

To resolve a suspect database: 
- Check the SQL Server error log and resolve all problems. 
- Reset the suspect status by executing sp_resetstatus. 



Resetting the Suspect Status
Microsoft� SQL Server� returns error 1105 and sets the status column
of sysdatabases to suspect if SQL Server is unable to complete
recovery on a database because the disk drive no longer has any free
space. Follow these steps to resolve the problem: 

Execute sp_resetstatus. 
Use ALTER DATABASE to add a data file or log file to the database. 
Stop and restart SQL Server. 
With the extra space provided by the new data file or log file, SQL
Server should be able to complete recovery of the database. 

Free disk space and rerun recovery. 
sp_resetstatus, shown below, turns off the suspect flag on a database
but leaves all other database options intact.


--------------------------------------------------------------------------------

Caution Use sp_resetstatus only when directed by your primary support
provider or as recommended in Troubleshooting. Otherwise, you might
damage your database.


--------------------------------------------------------------------------------

Because this procedure modifies the system tables, the system
administrator must enable updates to the system tables before creating
this procedure. To enable updates, use this procedure:

USE master

GO

sp_configure 'allow updates', 1

GO

RECONFIGURE WITH OVERRIDE

GO

  

After the procedure is created, immediately disable updates to the
system tables:

sp_configure 'allow updates', 0

GO

RECONFIGURE WITH OVERRIDE

GO

  

sp_resetstatus can be executed only by the system administrator.
Always shut down SQL Server immediately after executing this
procedure.

The syntax is

sp_resetstatus database_name

This example turns off the suspect flag on the PRODUCTION database.

sp_resetstatus PRODUCTION

  

Here is the result set:

Database 'PRODUCTION' status reset!

WARNING: You must reboot SQL Server prior to accessing this database!

  

sp_resetstatus Stored Procedure Code
Here is the code of the sp_resetstatus stored procedure:

CREATE PROC sp_resetstatus @dbname varchar(30) AS

DECLARE @msg varchar(80)

IF @@trancount > 0

        BEGIN

            PRINT "Can't run sp_resetstatus from within a
transaction."

            RETURN (1)

        END

IF suser_id() != 1

        BEGIN

            SELECT @msg =  "You must be the System Administrator (SA)"

            SELECT @msg = @msg + " to execute this procedure."

            RETURN (1)

        END

IF (SELECT COUNT(*) FROM master..sysdatabases

            WHERE name = @dbname) != 1

        BEGIN

            SELECT @msg = "Database '" + @dbname + "' does not exist!"

            PRINT @msg

            RETURN (1)

        END

IF (SELECT COUNT(*) FROM master..sysdatabases

            WHERE name = @dbname AND status & 256 = 256) != 1

        BEGIN

            PRINT "sp_resetstatus can only be run on suspect
databases."

            RETURN (1)

        END

BEGIN TRAN

        UPDATE master..sysdatabases SET status = status ^ 256

            WHERE name = @dbname

        IF @@error != 0 OR @@rowcount != 1

            ROLLBACK TRAN

        ELSE 

            BEGIN

                COMMIT TRAN

                SELECT @msg = "Database '" + @dbname + "' status
reset!"

                PRINT @msg

                PRINT " " 
                PRINT "WARNING: You must reboot SQL     Server prior
to  "

                PRINT "         accessing this database!"

                PRINT " "

            END

  

GO
Technical Details
Message-ID: <hdgjitsce1vph50b3u2i5pieu95dv45rph@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!proxad.net!fr.usenet-edu.net!usenet-edu.net!news.tele.dk!not-for-mail
References: <y4iW6.2765$VQ4.263013@news010.worldonline.dk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: fcdf9,bdcebcf736973453
X-Google-Attributes: gidfcdf9,public
X-Google-ArrivalTime: 2001-06-15 01:07:01 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!proxad.net!fr.usenet-edu.net!usenet-edu.net!news.tele.dk!not-for-mail
From: JH <newsfilter2@dk2net.dk>
Newsgroups: dk.edb.database
Subject: Re: Suspect database?
Date: Fri, 15 Jun 2001 10:07:58 +0200
Message-ID: <hdgjitsce1vph50b3u2i5pieu95dv45rph@4ax.com>
References: <y4iW6.2765$VQ4.263013@news010.worldonline.dk>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Lines: 190
Organization: TDC Internet
NNTP-Posting-Host: 62.242.172.177
X-Trace: 992592574 dread03.news.tele.dk 28137 62.242.172.177
X-Complaints-To: abuse@post.tele.dk