Friday, February 10, 2012

cannot repair database.

I startup sqlserver2005 in single user mode (sqlservr.exe -m under dos
mode).
open a new dos prompt to enter sqlcmd -Usa, and give password of sa to enter
sqlcmd.
type the following clause,
DBCC CHECKDB ('CK', REPAIR_ALLOW_DATA_LOSS);
go
I got 'repair statement not processed, database need to be in single user
mode' error messsage.
WHY? which one step I lost?
--FrankFrank Lee wrote:
> I startup sqlserver2005 in single user mode (sqlservr.exe -m under dos
> mode).
> open a new dos prompt to enter sqlcmd -Usa, and give password of sa to enter
> sqlcmd.
> type the following clause,
> DBCC CHECKDB ('CK', REPAIR_ALLOW_DATA_LOSS);
> go
> I got 'repair statement not processed, database need to be in single user
> mode' error messsage.
> WHY? which one step I lost?
> --Frank
>
You don't need to start up SQL Server with the -m switch.
Go into Management Studio, right click on the CK database, click on
properties.
In the resulting dialog select the "Options" page. In the right pane,
scroll down to "State" and change "Restrict Access" to a value of "Single".
This will put the DATABASE into single user mode.
Alternatively, you could use ALTER DATABASE:
ALTER DATABASE CK
SET SINGLE_USER;
GO
and
ALTER DATABASE CK
SET MULTI_USER;
GO
to change it back.
Rob|||ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/92d4714b-95bf-46af-b05e-759a7164f937.htm
--
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"Frank Lee" <Reply@.to.newsgroup> wrote in message
news:uzHfXT1DGHA.3988@.TK2MSFTNGP12.phx.gbl...
>I startup sqlserver2005 in single user mode (sqlservr.exe -m under dos
>mode).
> open a new dos prompt to enter sqlcmd -Usa, and give password of sa to
> enter sqlcmd.
> type the following clause,
> DBCC CHECKDB ('CK', REPAIR_ALLOW_DATA_LOSS);
> go
> I got 'repair statement not processed, database need to be in single user
> mode' error messsage.
> WHY? which one step I lost?
> --Frank
>|||>
> You don't need to start up SQL Server with the -m switch.
> Go into Management Studio, right click on the CK database, click on
> properties.
> In the resulting dialog select the "Options" page. In the right pane,
> scroll down to "State" and change "Restrict Access" to a value of
> "Single".
> This will put the DATABASE into single user mode.
> Alternatively, you could use ALTER DATABASE:
> ALTER DATABASE CK
> SET SINGLE_USER;
> GO
> and
> ALTER DATABASE CK
> SET MULTI_USER;
> GO
> to change it back.
>
> Rob
Thanks. It works for me.

No comments:

Post a Comment