restore backup database with out sql server management studio - sql

I have one database backup.
Now i want to install this backup to my friend's system.
His system does not contain SQL Server Management Studio.
How can i install my backup to his system, both are using SQL server 2005.

Statement 1: His system does not contain SQL server management studio
Statement 2: both are using SQL server 2005...
Doesn't the above two statements Contradict each other?
Update Please Ignore my Previous Answer
Run the following Command on Command Promt:
SqlCmd -E -S MyServer –Q “RESTORE DATABASE [MyDB]
FROM DISK=’D:BackupsMyDB.bak(Your backup Databse file)’”
I got the refrence from here

You will need some kind of SQL client on the other computer. As sqlcmd is part of any SQL Server installation that can be used.
Then use the RESTORE (SQL) statement to restore the backup.
Details about the RESTORE statement can be found in the manual: http://msdn.microsoft.com/en-US/library/ms190372%28v=sql.90%29.aspx
You can use any SQL client that is able to connect to the SQL Server on the second computer to run that.
To make things easier, you could use your SSMS instance to let it generate the necessary SQL statement. Just pretend to restore the backup on your computer and use the "Generate Script" dropdown at the top of the dialog to see the SQL that would have been run by SSMS.

Related

Unable to find Restore Database Option in SSMS

I am trying to restore a .bak file in my SQL Server using SSMS.
However I am unable to find the Restore Database option in the menu bar, when I right-clicked on Database.
What can be the possible reason for that?
Do I need to change some SSMS settings.
I am using SQL Server Management Studio 2014.
It's not possible to restore a .bak file to an Azure SQL Database. To migrate data to an Azure SQL Database, see this documentation: https://azure.microsoft.com/en-us/documentation/articles/sql-database-cloud-migrate/

How to find SQL Server name in logging in to SQL Server Management Studio

How can I create a server name for database engine in logging in to SQL Server Management Studio?
Or how can I find my default server name? I have been using running SQLCMD -L this code in my command prompt but it turns me nothing it just says Servers:
You can try using Localhost or . to connect to your local instance.
Also, to reattach your database (from the mdf file), you can use the Attach Database command that is showed in the following image.
Hope this helps

How to copy a SQL Server 2005 database from local to the server

I want to export database from local computer to database server in SQL Server 2005.
How can I restore database without having access to file system of database server
You can use SQL Server's built-in backup and restore functions.
Make a backup of your local database, and write it on some network share (can be anywhere in the network, doesn't have to be on the database server):
BACKUP DATABASE MyDatabase TO DISK = '\\Servername\Share\MyBackup.bak'
Then, you can restore the database on the database server, reading the backup directly from the network share:
RESTORE DATABASE MyDatabase FROM DISK = '\\Servername\Share\MyBackup.bak'
Note that you have to everything in T-SQL to be able to read and write directly to network shares!
(You can also backup and restore databases from the GUI in SQL Server Management Studio, but you can only use local folders there)
Your situation is, you want to copy the database from your local to remote database server but you do have access to the remote machine thats why you cannot use a restore or attach database function.
Solution:
For me the best thing to do is generate a script that will include the schema and the data of the database. This will serve as a script backup of your local database which can be run to any sql servers that you wanted. Sql Server 2008 already have the interface for this but for Sql Server 2005 you will need to have Sql Publishing Wizard.
You can download it from here: (remove spaces)
http: //www.codeplex.com/sqlhost/Wiki /View.aspx?title=Database%20Publishing%20Wizard
To create a script you can do this:
Command to run which will create schema and database:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql”
Command to run which will create schema:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -schemaonly
Command to run which will create data:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -dataonly
For more details please read...(Remove Spaces)
http: //blog.sqlauthority.com/2007/11/16/ sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/
This worked for me a lot of times.
You will need access to the file system of the database server.
You have to detach the database from your local server and then copy the related .mdf and .ldf files to the target database server and then attach the files in the SQL server management studio of that database server.

SQL Server 2008 Version Problem [duplicate]

I am getting following error.
Restore failed for Server
I have recently upgraded SQL Server 2005 Express to SQL Server 2008 Express.
I have taken a Backup on Production Server, having SQL Server 2008
Backup was good and I tried restoring Backup on Production Server, that works great.
Than I downloaded that backup file in .Zip format with FileZila Software (And that is good too).
But when I tried to restore that file I am getting following error.
Restore failed for Server
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------ ADDITIONAL INFORMATION:
The media family on device 'C:\go4sharepoint_1384_8481.bak' is incorrectly formed. SQL Server cannot process this media family. RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3241)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.4053&EvtSrc=MSSQLServer&EvtID=3241&LinkId=20476
Things I tried which didn't worked
Attempt 1
Try to take backup using following command
BACKUP DATABASE go4sharepoint_1384_8481
TO DISK='C:\HostingSpaces\dbname_jun14_2010_new.bak' with FORMAT
And tried restore that file.
Attempt 2
Somebody wrote to test Version of my SQL Server.
When I tried to run following command in SQL Server 2008
Select ##Version
It is giving following output
Microsoft SQL Server 2005 - 9.00.4053.00 (Intel X86) May 26 2009 14:24:20 Copyright (c) 1988-2005 Microsoft Corporation Express Edition on Windows NT 6.0 (Build 6002: Service Pack 2)
My Production Database is in SQL Server 2008, and I am trying to restore DB in SQL Server 2008 but above version is showing as if i am using SQL Server 2005.
Any idea how can I restore SQL Server 2008 DB.
Many Thanks.
Is it possible that, instead of upgrading your 2005 instance to 2008, you instead installed 2008 side-by-side with 2005, and you're connecting to your existing 2005 instance? Look for other instances on your machine.
You cannot restore a backup from a higher SQL Server version on a lower version - this has never been able in SQL Server.
If you have a SQL Server 2008 backup, you can only restore that on a SQL Server 2008 (or later) machine - but not on a 2005 box. No trick, no workaround, no way to do it.
You have 2 options here.
Use WITH REPLACE while using the RESTORE command. This will overwrite the existing database and restore the database state represented by the backup files.
Delete the database to which you are trying to restore to and restore again using RESTORE command. This will create a new database with the state represented by the backup files.
Please note that in both these options you will lose the existing data of the database you are trying to restore to.
Make sure it is installed correctly - in your program files\microsoft sql server directory there whould be a 100/150 folder. Check out the install log in setup bootstrap\log.
As described above the reason for this behaviour is that by default SQL Server doesn't allow restoring a database backup to an older version of SQL Server, regardless of the compatibility level of the database the backup was taken from.
You can try to:
Start SQL Server Management Studio and connect to the instance where the database resides
In the database context menu navigate to Tasks | Generate Scripts…. This will invoke the Generate and Publish Scripts wizard
In the Introduction step of the wizard click Next
In the Choose Objects step of the wizard make sure that the Script entire database and all database objects option is selected and click Next
In the Set Scripting options step of the wizard:
Select the Save scripts to a specific location option
Specify whether the database objects and data will be scripted to a single file multiple files, as well as the path and encoding of the generated scripts
Click Advanced
In the Advanced Scripting Options dialog that will appear:
Specify the version of the SQL Server you need the database restored to in the Script for Server Version option
In the Script for Server Version option specify Schema and data
Set the following options to True:
Script Logins
Script Full-Text Indexes
Script Triggers
Click OK
Click Next
In the Summary step of the wizard click Next
In the Save or Publish Scripts step of the wizard click Finish
Execute the generated SQL script(s) against the older SQL instance
Although the procedure listed above should work:
1. It doesn’t migrate all of the database objects (e.g. sequences or queues)
2. It might fail if your database contains dependencies which SQL Server fails to recognize (e.g. dependencies to databases residing on linked servers)
You can take a look at the rest of the article on Solution center. There is also third party tools you can take in consideration.

Importing Sql Server 2005 database into Sql Server express 2008

Is there any way to import a database backup from 2005 into 2008 express edition. What I've had to resort to is doing a script the database, then import all the data through DTS. Whenever I tried to import straight from a backup file it says something about not being to import into a new version of sql server or I'll get the below error.
title: Microsoft SQL Server Management Studio
Specified cast is not valid. (SqlManagerUI)
SQL 2005 backups should be restored on 2008 without problem (have done that myself many times). What exact error message did you got about versions?
The other error (Specified cast is not valid) seems to be Management Studio error, not server error. Have you full rights on 2008 server?
Look at this question - any-reason-to-have-sql-server-2005-and-2008-installed-on-same-machine - there are talked both about restoring SQL2005 backups and about attaching SQL2005 data files.
(Of course you cannot attach production databases. To attach non-production databases just detach them, make file level copy of these and attach copies to new server. Orginal files need to attach to original server too :))
I imagine that you are in a development process where your data will have to be regularly copied to you SQL 2008 server.
You can then think of configuring a replication between the SQL 2005 server (publisher) and SQL Server Express 2008 (suscriber). Depending on your requirements, you have the choice between snapshot or merge replication. If no update is done on the suscriber side, go for snapshot.
Once you want to have your 2008 server running independantely from the publisher, just delete the replication.
A valid SQL Server 2005 Express backup file should be able to be restored to SQL Server 2008 Express. If the SQL Server 2005 backup is from the Standard or Enterprise versions, you might hit problems restoring it to Express. The user context that the backup was created from should not affect the ability to restore that backup.
One thing you can do is to try running the restore operation as a verification, without actually trying to run the restore. That will tell you if the backup file is valid or not. You can use this syntax:
RESTORE VERIFYONLY
FROM yourbackupfile.bak
If possible, I would also suggest trying to simply detach the original database from 2005 and then attaching the file at the 2008 edition.
While I have only tried this with the standard edition myself, it has worked perfectly with the compatibility mode keeping the database set to 2005.
Have you tried running the Upgrade Advisor http://www.microsoft.com/download/en/details.aspx?id=11455 - it might be able to highlight problems for upgrading the original database.