简体   繁体   中英

How to take a hot backup from a database SQL Server Express

Is it possible to take a HOT backup from a database SQL Server EXPRESS (2012 or less) by using C# code?

I've seen this article but it doesn't seem to be usable for a HOT backup.

Another solution might be to execute the query "Backup Database ... to disk ..."; how would I launch that?

Yes you can

You can make a call to the backup command in SQL to make a hot backup BACKUP DATABASE [mydb] TO DISK = N'mydb.BAK' WITH NOFORMAT, INIT

Which will write a file to disk.

SqlCommand cmd = new SqlCommand ("BACKUP DATABASE [mydb] TO  DISK = N'mydb.BAK' WITH NOFORMAT, INIT", connection);
cmd.ExecuteNonQuery();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM