HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

How to backup/restore SQL Server database from command line similar to mysql

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
linesqldatabasemysqlhowservercommandfromsimilarrestore

Problem

I need to automate the migration for some databases from an older server. I know that script a tool using C# for example can be a possibility but I need a simple, fast and effective solution in order to build a batch file to do the job.

Solution

Create a .sql file with your backup / restore statement(s) and use SQLCMD

About halfway down that article there is an example of doing a backup.

You can refer to the following pages with information on the T-SQL for doing backups and restores:

  • Backup



  • Restore

Context

StackExchange Database Administrators Q#23518, answer score: 10

Revisions (0)

No revisions yet.