sql2005备份在sql2000中恢复
Http://www.Egocbd.com 点击数: 更新时间:2010-2-3 10:44:28
@retype= DB or @retype= DBNOR
begin
--从备份文件中获取逻辑文件名
declare @lfn nvarchar(128),@tp char(1),@i int
--创建临时表,保存获取的信息
create table #tb(ln nvarchar(128),pn nvarchar(260),tp char(1),fgn nvarchar(128),sz numeric(20,0),Msz numeric(20,0))
--从备份文件中获取信息
insert into #tb exec( restore filelistonly from disk= +@bkfile+ )
declare #f cursor for select ln,tp from #tb
open #f
fetch next from #f into @lfn,@tp
set @i=0
while @@fetch_status=0
begin
select @sql=@sql+ ,move +@lfn+ to +@dbpath+@dbname+cast(@i as varchar)
+case @tp when D then .mdf else .ldf end
,@i=@i+1
fetch next from #f into @lfn,@tp
end
close #f
deallocate #f
end
--关闭用户进程处理
if @overexist=1 and @killuser=1
begin
declare @spid &n
begin
--从备份文件中获取逻辑文件名
declare @lfn nvarchar(128),@tp char(1),@i int
--创建临时表,保存获取的信息
create table #tb(ln nvarchar(128),pn nvarchar(260),tp char(1),fgn nvarchar(128),sz numeric(20,0),Msz numeric(20,0))
--从备份文件中获取信息
insert into #tb exec( restore filelistonly from disk= +@bkfile+ )
declare #f cursor for select ln,tp from #tb
open #f
fetch next from #f into @lfn,@tp
set @i=0
while @@fetch_status=0
begin
select @sql=@sql+ ,move +@lfn+ to +@dbpath+@dbname+cast(@i as varchar)
+case @tp when D then .mdf else .ldf end
,@i=@i+1
fetch next from #f into @lfn,@tp
end
close #f
deallocate #f
end
--关闭用户进程处理
if @overexist=1 and @killuser=1
begin
declare @spid &n