SQL脚本
GO
DECLARE
@backupTime VARCHAR(20)
DECLARE
@fileName VARCHAR(1000)
SELECT
@backupTime=(CONVERT(VARCHAR(8), GETDATE(), 112) +REPLACE(CONVERT(VARCHAR(5), GETDATE(), 114), ':', ''))
SELECT
@fileName='F:\Database_Backup\DB_'+@backupTime+'.bak'
backup database zm9 to disk=@fileName
BAT
C:\Windows\system32>sqlcmd -S localhost -U sa -P XXXXX -i f:\backup.sql