什么数据库:SqlServer?oracle?mysql?
可以用执行存储过程的方式运行数据库备份
-----数据备份
SET NOCOUNT ON;
use master
declare @Database nvarchar(256),@Path nvarchar(2048)
select @Database=N'OA',@Path=N'd:\DataBak\bak\' ----备份保存路径
declare @sql nvarchar(max)
select @sql =N'BACKUP DATABASE '+@Database+N'
TO DISK = '''+@Path+@Database+N'_Full_'+REPLACE(REPLACE(REPLACE(REPLACE(convert(nvarchar(30),getdate(),121),'-',''),':',''),'.',''),' ','')+N'.bak''
WITH
NOFORMAT,
INIT,
NAME = N''Full Database Backup'',
SKIP'
exec (@sql)
SELECT '1' [FLAG]
----日志备份
SET NOCOUNT ON;
use master
declare @Database nvarchar(256),@Path nvarchar(2048)
select @Database=N'OA',@Path=N'd:\DataBak\bak\'
declare @sql nvarchar(max)
select @sql =N'BACKUP LOG '+@Database+N'
TO DISK = '''+@Path+@Database+N'_Log_'+REPLACE(REPLACE(REPLACE(REPLACE(convert(nvarchar(30),getdate(),121),'-',''),':',''),'.',''),' ','')+N'.trn'''
exec (@sql)
SELECT '1' [FLAG]