要怎么才能还原本地bak数据库到远程服务器?
4 个解决方案
#1
在查询分析器中连接到远程计算机.
--恢复数据库
restore database 数据库名 from disk='x:\path\备份文件.bak'
#2
CREATE proc RestoreDb @bkfile nvarchar(1000),@dbname sysname='',@dbpath nvarchar(260)='',@retype nvarchar(10)='DB',@filenumber int=1, @overexist bit=1,@killuser bit=1
as declare @sql varchar(8000) if isnull(@dbname,'')=''select @sql=reverse(@bkfile),@sql=case when charindex('.',@sql)=0 then @sql else substring(@sql,charindex('.',@sql)+1,1000) end ,@sql=case when charindex('\',@sql)=0 then @sql else left(@sql,charindex('\',@sql)-1) end,@dbname=reverse(@sql)
set @sql='restore '+case @retype when 'LOG' then 'log ' else 'database ' end+@dbname+' from disk='''+@bkfile+''''+' with file='+cast(@filenumber as varchar) +case when @overexist=1 and @retype in('DB','DBNOR') then ',replace' else '' end +case @retype when 'DBNOR' then ',NORECOVERY' else ',RECOVERY' end
print @sql
if @overexist=1 and @killuser=1
begin declare @spid varchar(20) declare #spid cursor for select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname) open #spid fetch next from #spid into @spid while @@fetch_status=0 begin exec('kill '+@spid) fetch next from #spid into @spid End close #spid deallocate #spid End
exec (@sql)
as declare @sql varchar(8000) if isnull(@dbname,'')=''select @sql=reverse(@bkfile),@sql=case when charindex('.',@sql)=0 then @sql else substring(@sql,charindex('.',@sql)+1,1000) end ,@sql=case when charindex('\',@sql)=0 then @sql else left(@sql,charindex('\',@sql)-1) end,@dbname=reverse(@sql)
set @sql='restore '+case @retype when 'LOG' then 'log ' else 'database ' end+@dbname+' from disk='''+@bkfile+''''+' with file='+cast(@filenumber as varchar) +case when @overexist=1 and @retype in('DB','DBNOR') then ',replace' else '' end +case @retype when 'DBNOR' then ',NORECOVERY' else ',RECOVERY' end
print @sql
if @overexist=1 and @killuser=1
begin declare @spid varchar(20) declare #spid cursor for select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname) open #spid fetch next from #spid into @spid while @@fetch_status=0 begin exec('kill '+@spid) fetch next from #spid into @spid End close #spid deallocate #spid End
exec (@sql)
#3
@bkfile 就是指我的bak文件名对吗?
#4
我用查询分析器进行restore数据库,
语句是“RESTORE DATABASE AAA FROM DISK = 'd:\AAA.bak'”
结果执行后显示:
消息 3110,级别 14,状态 1,第 1 行
用户没有 RESTORE 数据库 'AAA' 的权限。
消息 3013,级别 16,状态 1,第 1 行
RESTORE DATABASE 操作异常终止。
请问是服务器供应商给的权限问题吗?一般购买数据库空间是供应商上传的数据库还是我们自己上传的啊?
语句是“RESTORE DATABASE AAA FROM DISK = 'd:\AAA.bak'”
结果执行后显示:
消息 3110,级别 14,状态 1,第 1 行
用户没有 RESTORE 数据库 'AAA' 的权限。
消息 3013,级别 16,状态 1,第 1 行
RESTORE DATABASE 操作异常终止。
请问是服务器供应商给的权限问题吗?一般购买数据库空间是供应商上传的数据库还是我们自己上传的啊?
#1
在查询分析器中连接到远程计算机.
--恢复数据库
restore database 数据库名 from disk='x:\path\备份文件.bak'
#2
CREATE proc RestoreDb @bkfile nvarchar(1000),@dbname sysname='',@dbpath nvarchar(260)='',@retype nvarchar(10)='DB',@filenumber int=1, @overexist bit=1,@killuser bit=1
as declare @sql varchar(8000) if isnull(@dbname,'')=''select @sql=reverse(@bkfile),@sql=case when charindex('.',@sql)=0 then @sql else substring(@sql,charindex('.',@sql)+1,1000) end ,@sql=case when charindex('\',@sql)=0 then @sql else left(@sql,charindex('\',@sql)-1) end,@dbname=reverse(@sql)
set @sql='restore '+case @retype when 'LOG' then 'log ' else 'database ' end+@dbname+' from disk='''+@bkfile+''''+' with file='+cast(@filenumber as varchar) +case when @overexist=1 and @retype in('DB','DBNOR') then ',replace' else '' end +case @retype when 'DBNOR' then ',NORECOVERY' else ',RECOVERY' end
print @sql
if @overexist=1 and @killuser=1
begin declare @spid varchar(20) declare #spid cursor for select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname) open #spid fetch next from #spid into @spid while @@fetch_status=0 begin exec('kill '+@spid) fetch next from #spid into @spid End close #spid deallocate #spid End
exec (@sql)
as declare @sql varchar(8000) if isnull(@dbname,'')=''select @sql=reverse(@bkfile),@sql=case when charindex('.',@sql)=0 then @sql else substring(@sql,charindex('.',@sql)+1,1000) end ,@sql=case when charindex('\',@sql)=0 then @sql else left(@sql,charindex('\',@sql)-1) end,@dbname=reverse(@sql)
set @sql='restore '+case @retype when 'LOG' then 'log ' else 'database ' end+@dbname+' from disk='''+@bkfile+''''+' with file='+cast(@filenumber as varchar) +case when @overexist=1 and @retype in('DB','DBNOR') then ',replace' else '' end +case @retype when 'DBNOR' then ',NORECOVERY' else ',RECOVERY' end
print @sql
if @overexist=1 and @killuser=1
begin declare @spid varchar(20) declare #spid cursor for select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname) open #spid fetch next from #spid into @spid while @@fetch_status=0 begin exec('kill '+@spid) fetch next from #spid into @spid End close #spid deallocate #spid End
exec (@sql)
#3
@bkfile 就是指我的bak文件名对吗?
#4
我用查询分析器进行restore数据库,
语句是“RESTORE DATABASE AAA FROM DISK = 'd:\AAA.bak'”
结果执行后显示:
消息 3110,级别 14,状态 1,第 1 行
用户没有 RESTORE 数据库 'AAA' 的权限。
消息 3013,级别 16,状态 1,第 1 行
RESTORE DATABASE 操作异常终止。
请问是服务器供应商给的权限问题吗?一般购买数据库空间是供应商上传的数据库还是我们自己上传的啊?
语句是“RESTORE DATABASE AAA FROM DISK = 'd:\AAA.bak'”
结果执行后显示:
消息 3110,级别 14,状态 1,第 1 行
用户没有 RESTORE 数据库 'AAA' 的权限。
消息 3013,级别 16,状态 1,第 1 行
RESTORE DATABASE 操作异常终止。
请问是服务器供应商给的权限问题吗?一般购买数据库空间是供应商上传的数据库还是我们自己上传的啊?