欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

备份还原数据库

程序员文章站 2024-02-04 15:52:40
...

创建存储过程 CREATE PROCEDURE protest ( @var1 int, @var2 int, @var3 int output ) AS set @var3=@var1+@var2+@var3 return @var3 GO 运用存储过程 declare @var1 int set @var1='1' declare @var2 int set @var2='2' declare @var3 int set @var3='3' ex

创建存储过程
CREATE PROCEDURE protest
(
@var1 int,
@var2 int,
@var3 int output
)
AS
set @var3=@var1+@var2+@var3
return @var3
GO

运用存储过程
declare @var1 int
set @var1='1'
declare @var2 int
set @var2='2'
declare @var3 int
set @var3='3'
exec protest @var1,@var2,@var3 output
select @var3

备份数据库
backup database pubs
to disk='c:/test/pubs.bak'

还原数据库
restore database test
from disk='c:/test/pubs.bak'
with move 'pubs' to 'c:/test/test.mdf',
move 'pubs_log' to 'c:/test/test.ldf'