请使用 WITH MOVE 选项来标识该文件的有效位置。



 

1 RESTORE FILELISTONLY FROM DISK  ='F:\公司项目\2012年12月\k恺威寰宇解决方案\恺威寰宇Web\App_Data\xclh(1).bak'
2 
3 RESTORE DATABASE [xclh] 
4 FROM DISK  ='d:\Program Files\Microsoft SQL Server\MSSQL\data\xclh.bak'
5 with 
6 move 'xclh_Data' to 'd:\Program Files\Microsoft SQL Server\MSSQL\data\xclh_Data.MDF',
7 move 'xclh_Log' to 'd:\Program Files\Microsoft SQL Server\MSSQL\data\xclh_Log.LDF'
8 

9

 

declare tb cursor local for
select 'sp_changeobjectowner ''['+replace(user_name(uid),']',']]')+'].['
+replace(name,']',']]')+']'',''dbo'''
from sysobjects 
where xtype in('U','V','P','TR','FN','IF','TF') and status>=0
open tb
declare @s nvarchar(4000)
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb
go
posted @ 2012-12-19 00:19  xyzhuzhou  阅读(1342)  评论(0编辑  收藏  举报