RECOVERING A DATABASE WITH SUSPECT STATUS

67
rate or flag this page

By oryzana


SYBASE DATABASE

 

To RECOVER THE DATABASE STATUS you need to run sp_resetstatus. If you don't have one, below are the steps on how to create and execute sp_resetstatus on WINDOWS platform for SYSBASE server.

  • 1) Go to start à run à cmd

  • 2) At cmd prompt type this command

C:\>isql -Uusernamehere -Sservernamehere

  • 3) To create and execute sp_resetstatus, take the following steps

At command prompt

1> use master

2> go

1> sp_configure "allow updates", 1

2> go

  • 4) Create the sp_resetstatus procedure in the master database.

Start à program à Sybase à Sybase central java edition

After that, write the following to the sp. Name it as sp_resetstatus

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
 

  • 5) after the procedure is created, at the command prompt type

1> use master

2> go

1> sp_configure "allow updates", 0

2> go

  • 6) to run sp_resetstatus, at the command prompt type

1> sp_resetstatus "databasename"

2> go

Print   —   Rate it:  up  down  flag this hub

Comments

RSS for comments on this Hub

No comments yet.

Submit a Comment

Members and Guests

Sign in or sign up and post using a hubpages account.


optional


  • No HTML is allowed in comments, but URLs will be hyperlinked
  • Comments are not for promoting your hubs or other sites

working