SQL SERVER 2005 报表数据库还原碰到的问题

 

   今天装了一下公司的的GES(服装生产线管理软件),装上以后发现报表管理中少了很多报表,有198个报表,怎么装上才68个,少了这么多。想个办法搞一下,有不想重新装报表,因为有几个hotfix ,装起来麻烦。所以我就想从其他的服务器上把报表copy 过来,这样省事,本人特别懒,关键是想搞点花样出来。好其心作怪。

 

有两台电脑,一台名字叫alex,一台叫sdt  .我要搞的是sdt,要恢复的数据库是:reportserver. 这个是个报表数据库。

第一步 :从alex 上把reportsever备份一下,然后到sdt上去还原。去还原的时候报错:

 

 

这个错误是说独占进程没有得到,因为数据库正在使用。这个错误可能是有一个以上的进程或者是用户在操作这个数据库,所以不能进行恢复。解决办法是把这个数据库设置成单用户模式,一次只让一个人使用。

 

  设置单用户模式的语句:

 use master


  alter database 数据库名  set single_user with rollback immediate

  或者

  alter database 数据库名  set single_user with no_wait

  或者

  exec sp_dboption '数据库名 ', 'single user','true'

 

  运行这个script 有报错:

   Msg 5070, Level 16, State 2, Line 1
   Database state cannot be changed while other users are using the database 'ReportServer'
   Msg 5069, Level 16, State 1, Line 1
   ALTER DATABASE statement failed.

 

   错误意思是还是有其他用户在使用这个数据库,或者是其他进程在使用。所以你不能设置成单用户模式。

  怎么办,有没有办法还: 在网上找到这样的解决方法:

 

 

In a case that you want to alter the database access mode from single user mode to multi user mode or from multi user mode to single user mode, you may have to kill all the active open connections to the database.

In such a case, you have to find all the open connections and run "Kill @spid " command to close all the connections.

For a list of open connections for a specific database you can run a similar command as below :

select spid from master..sysprocesses where dbid = db_id('Works') and spid <> @@spid

The second part of the task will be closing the open connections with the Kill command. This can be achived by running kill commands within a cursor or creating a dynamic sql command which kills the active connections to the related database.

Let's code the closing open connections using a t-sql cursor:

 

 DECLARE @DatabaseName nvarchar(50)
DECLARE @SPId int

SET @DatabaseName = N'Works'

DECLARE my_cursor CURSOR FAST_FORWARD FOR
SELECT SPId FROM MASTER..SysProcesses WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId

OPEN my_cursor

FETCH NEXT FROM my_cursor INTO @SPId

WHILE @@FETCH_STATUS = 0
BEGIN
KILL @SPId

FETCH NEXT FROM my_cursor INTO @SPId
END

CLOSE my_cursor
DEALLOCATE my_cursor

 


这段英文的意思是要把跟reportserver 连接的所有进程都杀掉,有两个方法

一个用 script ,一个用游标。

我用的是script :

   用这个找到所有跟reportserver有关的进程:

  select spid from master..sysprocesses where dbid = db_id('Works') and spid <> @@spid

 

然后用 kill spid 把找到的进程id一个一个杀掉,如果只有一个,就用这个,如果有多个用游标。

 

 杀了以后在跑:

 

    use master

 

  alter database 数据库名  set single_user with rollback immediate

  或者

  alter database 数据库名  set single_user with no_wait

  或者

  exec sp_dboption '数据库名 ', 'single user','true'

 

 这样reportserver 就变成单用户模式,重新启动sql 的服务,打开sql server 2005可以看到reportserver数据库上有一个人头的样子,后面是(single user) .

  这下就可以还原数据库了。

 

  还原之后要把reportserver 设置成多用户模式:有两种方法。

 

  一种:

     

 

 

  可以设置是单用户模式还是多用户模式。

 

另外一种方法是用script :

   use master

alter database reportserver set  muliple_user

 

到这里reportserver 数据库的恢复工作就做完了。

 

   接下来就是要检查报表能不能运行的问题:

 

   打开IE浏览器,输入:http://localhost/reportserver. 报错,错误如下:

 

 

The report server installation is not initialized. (rsReportServerNotActivated) (rsRPCError) Problem

 

    解决办法:go to start --->all programs-->Sql server 2005--->reporting Services---->Configuration --->Inslizing reporting service then press intilizing button then work it will work fine

 

 


 

   左边栏位中的Initialization 是个红叉,说明要初始化的就是他了。

 

 


 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值