DECLARE @fileName nvarchar(100)
SET @fileName='D:\HFS\DataBase' + REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(100), GETDATE(), 121), ' ', ''), ':', ''), '-', ''), '.', '') + '.bak'
BACKUP DATABASE [HFBaseData] TO DISK = @fileName WITH NOINIT , NOUNLOAD , NAME = N'数据库-备份', NOSKIP , STATS = 10, NOFORMAT
转载于:https://www.cnblogs.com/yelanggu/p/7079032.html