SET QUOTED_IDENTIFIER OFF select @cmd = BACKUP LOG [+@databasename+] TO DISK = N+@filename+ WITH INIT , NOUNLOAD , NAME = N+@filename +LOG Backup, NOSKIP , STATS = 10, NOFORMAT http://blog.csdn.net/downmoon/archive/2007/06/05/1639398.aspx
GO
SET ANSI_NULLS OFF
GO
ALTER PROCEDURE CPP_BackDataBase@databasename varchar(100)) AS
declare @filename varchar(100),@cmd varchar(255)
select @databasename = rtrim(@databasename)
select @filename = c:sqlbackup+ rtrim(convert(varchar(10),getdate(),20))
set @cmd = md +@filename
exec master.dbo.xp_cmdshell @cmd
select @filename = @filename ++@databasename + rtrim(convert(varchar(10),getdate(),20))
select @filename = ltrim(rtrim(@filename))
select @cmd =BACKUP DATABASE[+@databasename+] TO DISK = N+@filename +.bak WITH INIT , NOUNLOAD , NAME = N +@filename+备份, SKIP , STATS = 10, FORMAT
exec (@cmd)
if(@databasename <> master and @databasename <>msdb)
begin
–backup log with truncate_only
select @filename = c:sqlbackup+@databasename+log.back
exec (@cmd)
select @cmd = backup log [+@databasename+] with truncate_only
exec (@cmd)
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
生成mssql data备份的存储过程_数据库技巧
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 生成mssql data备份的存储过程_数据库技巧
相关推荐
-      sql语句中的判断功能的使用方法
-      sql语句中的判断功能的使用方法
-      SQL语言中去掉小数点有效数字后面的所有0
-      在sql语句中实现md5功能
-      ASP连接各种数据库的代码
-      给access数据库减肥
-      asp连接access数据库代码(2)
-      更改 SQL Server 登录模式