第一种
DECLARE @sql VARCHAR(500),@DBNAME SYSNAME
SET @DBNAME = '数据库名'
SET @sql = 'BACKUP DATABASE [' + @DBNAME + '] TO DISK = ''路径' + @DBNAME + '_FULL_BAK_' +CONVERT(VARCHAR,GETDATE(),112)+ '.bak'''
EXEC(@sql)
第二种
DECLARE @sql VARCHAR(500),@DBNAME SYSNAME
SET @DBNAME = '数据库名'
SET @sql = 'BACKUP DATABASE [' + @DBNAME + '] TO DISK = ''路径'+replace(replace(CONVERT(VARCHAR,GETDATE()),' ',''),':','-')+ '.bak'''
EXEC(@sql)