Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Suspect Database

Author  Topic 

rbohaty
Yak Posting Veteran

71 Posts

Posted - 2001-11-30 : 19:38:58
I have a SQL 6.5 server that because of hardware problems with a raid array has a suspect database. Now when SQL server comes up I have one database (that existed on the messed up raid) that is suspect. I have a backup of the db, but I cannot do a restore with the db in suspect status. I have read about a stored procedure sp_resetstatus, but that sp does not exist on my server. Is there a way to get my db out of suspect status?

Thanx

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2001-11-30 : 19:55:27
This would just be a work-around, but can you restore from your backup into a new (different named) database? If you can do this, then can you delete or detach the corrupt one and rename the new one?


-------------------
It's a SQL thing...
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2001-11-30 : 19:57:10
By the way, if you want to mess with it, here's the code for sp_resetstatus from a SQL 7 box (taken from sp_helptext sp_resetstatus). Use at your own risk!


CREATE PROCEDURE sp_resetstatus -- 1995/11/30 14:12 #12092
@DBName sysname
as

Set nocount on

Declare
@msg nvarchar(280)
,@RetCode integer
,@_error integer
,@_rowcount integer
,@int1 integer
,@bitSuspect integer
,@mode integer
,@status integer

Select
@RetCode = 0 -- 0=no_problem, 1=some_problem

--------------------- Restrict to SA -------------------------

IF suser_id() <> 1
begin
RaisError(15003,-1,-1,'sysadmin')
Select @RetCode = 1
GOTO LABEL_86BYEBYE
end


------------------ Get SuspectBit id value ------------------

SELECT @bitSuspect = min(number)
from
master..spt_values
where type = 'D '
and name = 'not recovered' -- 256, Suspect

---------------------- Forbid active txn ---------------------

--- (Prior spt_values Sel trips SET implicit_transactions!)


IF @@trancount > 0
begin
RaisError(15002,-1,-1,'sp_resetstatus')
Select @RetCode = 1
GOTO LABEL_86BYEBYE
end


--------------- Obtain/Report pre-Update values --------------------

SELECT
@mode = min(mode)
,@status = min(status)
from
master..sysdatabases
where name = @DBName

IF @@error <> 0 OR @status IS Null
begin
RaisError(15010,-1,-1,@DBName)
Select @RetCode = 1
GOTO LABEL_86BYEBYE
end


Select @int1 = @status & @bitSuspect


Raiserror(15052,-1,-1 ,@DBName ,@mode ,@status ,@int1)

--------------------- Update sysdatabases row ---------------------

BEGIN TRANSACTION


UPDATE
master..sysdatabases
set
mode = 0
,status = status & (~ @bitSuspect)
where name = @DBName
and
(mode <> 0 OR
status & @bitSuspect > 0
)

Select @_error = @@error ,@_rowcount = @@rowcount


IF @_error <> 0
begin

ROLLBACK TRANSACTION

RaisError(15055,-1,-1)
Select @RetCode = 1
GOTO LABEL_86BYEBYE
end


COMMIT TRANSACTION

-------- Report the results

IF @_rowcount = 0
begin
Raiserror(15056,-1,-1)
end

ELSE
begin

Raiserror(15073,-1,-1, @DBName,@bitSuspect)

Raiserror(15074,-1,-1)

end


LABEL_86BYEBYE:

RETURN @RetCode


-------------------
It's a SQL thing...

Edited by - AjarnMark on 11/30/2001 19:57:30
Go to Top of Page

rbohaty
Yak Posting Veteran

71 Posts

Posted - 2001-11-30 : 21:38:04
Thanx for the help, after doing a little more research i ran the instsup.scr??? from the install location of the sql 6.5 server and that created the sp_resetstatus. Ran sp_resetstatus on my db and the restore completed with no problems. Back up and running.

thanx all....

Go to Top of Page
   

- Advertisement -