sql2005备份在sql2000中恢复
Http://www.Egocbd.com 点击数: 更新时间:2010-2-3 10:44:28
时间
@bktype nvarchar(10)= DB , --备份类型: DB 备份数据库, DF 差异备份, LOG 日志备份
@appendfile bit=1 --追加/覆盖备份文件
as
declare @sql varchar(8000)
if isnull(@dbname, )= set @dbname=db_name()
if isnull(@bkpath, )= set @bkpath=dbo.f_getdbpath(null)
if isnull(@bkfname, )= set @bkfname= DBNAME\_DATE\_TIME.BAK
set @bkfname=replace(replace(replace(@bkfname, DBNAME ,@dbname)
, DATE ,convert(varchar,getdate(),112))
, TIME ,replace(convert(varchar,getdate(),108), : , ))
set @sql= backup +case @bktype when LOG then log else database end +@dbname
+ to disk= +@bkpath+@bkfname
+ with +case @bktype when DF then DIFFERENTIAL, else end
+case @appendfile when 1 then NOINIT else INIT end
print @sql
exec(@sql)
go
----------------------------------------------------------------------
--完整恢复数据库
exec p_RestoreDb @bkfile= c:db_20031015_db.bak ,@dbname= db  
@bktype nvarchar(10)= DB , --备份类型: DB 备份数据库, DF 差异备份, LOG 日志备份
@appendfile bit=1 --追加/覆盖备份文件
as
declare @sql varchar(8000)
if isnull(@dbname, )= set @dbname=db_name()
if isnull(@bkpath, )= set @bkpath=dbo.f_getdbpath(null)
if isnull(@bkfname, )= set @bkfname= DBNAME\_DATE\_TIME.BAK
set @bkfname=replace(replace(replace(@bkfname, DBNAME ,@dbname)
, DATE ,convert(varchar,getdate(),112))
, TIME ,replace(convert(varchar,getdate(),108), : , ))
set @sql= backup +case @bktype when LOG then log else database end +@dbname
+ to disk= +@bkpath+@bkfname
+ with +case @bktype when DF then DIFFERENTIAL, else end
+case @appendfile when 1 then NOINIT else INIT end
print @sql
exec(@sql)
go
----------------------------------------------------------------------
--完整恢复数据库
exec p_RestoreDb @bkfile= c:db_20031015_db.bak ,@dbname= db