string query = "BACKUP DATABASE DbName TO DISK = 'C:\\app\\dbName.Bak' WITH FORMAT, MEDIANAME = 'dbName', NAME = 'Full Backup of dbName';";
这是我正在使用的查询,我想为每个备份添加一个时间戳到.Bak文件的名称。
答案 0 :(得分:1)
使用字符串格式:
string query = string.Format("BACKUP DATABASE DbName TO DISK = 'C:\\app\\dbName{0}.Bak' WITH FORMAT, MEDIANAME = 'dbName', NAME = 'Full Backup of dbName';", DateTime.Now.ToString("yyyyMMdd"));
答案 1 :(得分:0)
使用此代码:
string query = string.Format( "Backup Database DbName To Disk='C:\\BackUp" + DateTime.Now.ToString("yyyy-MM-dd") + ".bak'");