Does any one know if there is a way to script out SQL Server backup in to a batch file, so that it could be executed from a command line?
相关问题
- sql execution latency when assign to a variable
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
- SQL to Parse a Key-Value String
相关文章
- Entity Framework 4.3.1 failing to create (/open) a
- How do you backup an apache Jackrabbit repository
- Code for inserting data into SQL Server database u
- Delete Every Alternate Row in SQL
- Compile and build with single command line Java (L
- Linux based PHP install connecting to MsSQL Server
- SQL Azure Reset autoincrement
- How do we alias a Sql Server instance name used in
if you need the batch file to schedule the backup, the SQL management tools have scheduled tasks built in...
Combine Remove Old Backup files with above script then this can perform backup by a scheduler, keep last 10 backup files
You can use sqlcmd to run a backup, or any other T-SQL script. You can find the detailed instructions and examples on various useful sqlcmd switches in this article: Working with the SQL Server command line (sqlcmd)
Here's an example you can run as a batch script (copy-paste into a .bat file), using the SQLCMD utility in Sql Server client tools:
BACKUP:
RESTORE:
I am using SQL Server 2005 Express, and I had to enable Named Pipes connection to be able to backup from the Windows Command. My final script is this:
It's working just fine here!!
Seba Illingworth's code, In case you need time in your file name (it gives 2014-02-21_1035)