How can I backup a database from command line and restore it from command li
ne? Can I restore database from command line over a database which is blank?You can use the osql utility to run T-SQL Queries from the command line, and
you can use the BACKUP and RESTORE T-SQL commands to backup and restore
databases.
For example:
osql -E -Q"BACKUP DATABASE Northwind TO FILE = 'Northwind.bak'"
will backup the Northwind database to the default backup directory.
See for more details Books Online.
Jacco Schalkwijk
SQL Server MVP
"SQL Starter" <anonymous@.discussions.microsoft.com> wrote in message
news:44A7DFD6-60A0-457C-9615-868F5023DC9D@.microsoft.com...
> How can I backup a database from command line and restore it from command
line? Can I restore database from command line over a database which is
blank?|||Hi ,
Yes, You can do both Backup and Restore using command line utilities OSQL or
ISQL.
c:\> OSQL -Uuser -Ppassword -S servername (Enter)
Now it will go to a SQL prompt:-
1> backup database dbname to disk='c:\backupdbname.bak' with init
2>go
The above commands will backup the database
1>restore database dbname from disk='c:\backup\dbname.bak'
2>go
The above command will restore
Thanks
Hari
MCDBA
"SQL Starter" <anonymous@.discussions.microsoft.com> wrote in message
news:44A7DFD6-60A0-457C-9615-868F5023DC9D@.microsoft.com...
> How can I backup a database from command line and restore it from command
line? Can I restore database from command line over a database which is
blank?
Showing posts with label comman. Show all posts
Showing posts with label comman. Show all posts
Wednesday, March 7, 2012
Backup and Restore from comman line
How can I backup a database from command line and restore it from command line? Can I restore database from command line over a database which is blank?
You can use the osql utility to run T-SQL Queries from the command line, and
you can use the BACKUP and RESTORE T-SQL commands to backup and restore
databases.
For example:
osql -E -Q"BACKUP DATABASE Northwind TO FILE = 'Northwind.bak'"
will backup the Northwind database to the default backup directory.
See for more details Books Online.
Jacco Schalkwijk
SQL Server MVP
"SQL Starter" <anonymous@.discussions.microsoft.com> wrote in message
news:44A7DFD6-60A0-457C-9615-868F5023DC9D@.microsoft.com...
> How can I backup a database from command line and restore it from command
line? Can I restore database from command line over a database which is
blank?
|||Hi ,
Yes, You can do both Backup and Restore using command line utilities OSQL or
ISQL.
c:\> OSQL -Uuser -Ppassword -S servername (Enter)
Now it will go to a SQL prompt:-
1> backup database dbname to disk='c:\backupdbname.bak' with init
2>go
The above commands will backup the database
1>restore database dbname from disk='c:\backup\dbname.bak'
2>go
The above command will restore
Thanks
Hari
MCDBA
"SQL Starter" <anonymous@.discussions.microsoft.com> wrote in message
news:44A7DFD6-60A0-457C-9615-868F5023DC9D@.microsoft.com...
> How can I backup a database from command line and restore it from command
line? Can I restore database from command line over a database which is
blank?
You can use the osql utility to run T-SQL Queries from the command line, and
you can use the BACKUP and RESTORE T-SQL commands to backup and restore
databases.
For example:
osql -E -Q"BACKUP DATABASE Northwind TO FILE = 'Northwind.bak'"
will backup the Northwind database to the default backup directory.
See for more details Books Online.
Jacco Schalkwijk
SQL Server MVP
"SQL Starter" <anonymous@.discussions.microsoft.com> wrote in message
news:44A7DFD6-60A0-457C-9615-868F5023DC9D@.microsoft.com...
> How can I backup a database from command line and restore it from command
line? Can I restore database from command line over a database which is
blank?
|||Hi ,
Yes, You can do both Backup and Restore using command line utilities OSQL or
ISQL.
c:\> OSQL -Uuser -Ppassword -S servername (Enter)
Now it will go to a SQL prompt:-
1> backup database dbname to disk='c:\backupdbname.bak' with init
2>go
The above commands will backup the database
1>restore database dbname from disk='c:\backup\dbname.bak'
2>go
The above command will restore
Thanks
Hari
MCDBA
"SQL Starter" <anonymous@.discussions.microsoft.com> wrote in message
news:44A7DFD6-60A0-457C-9615-868F5023DC9D@.microsoft.com...
> How can I backup a database from command line and restore it from command
line? Can I restore database from command line over a database which is
blank?
Subscribe to:
Posts (Atom)