SqlAgent备份脚本

declare @dbname varchar(255)
declare @back_path varchar(255)
set @dbname=emcp
set @back_path= e:\+@dbname+\+@dbname
    +convert(varchar(9),getdate(),112)
    +CAST(datepart(hour,getdate()) as char(2))
    +CAST(datepart(minute,getdate()) as char(2))
    +CAST(datepart(second,getdate()) as CHAR(2))
    +.bak

exec(use [+@dbname+])
exec(backup database [+@dbname+] to disk=‘‘‘+@back_path+‘‘‘‘)

 

SqlAgent备份脚本

上一篇:SQL语句的强化


下一篇:URL编码