Moving a SQL Server database from Visual Studio to SQL Server Manager - sql

I've created a local database in Visual Studio 2015 and I need to move it to another machine that is using SQL Server Management Studio so that the TA marking my assignment can have access to it. What is the easiest way to move the database from one machine to another? I really don't want to have to start from scratch again on the new machine.

I'm thinking the easiest would be to backup the database from Visual Studio then restore it onto Server Manager. I don't use either so I'm not entirely sure how to do it for those specific applications, but you can always do sql queries!
backup:
BACKUP DATABASE databasename TO disk = 'c:\t.bak'
restore:
RESTORE DATABASE databasename FROM DISK = 'c:\t.bak'

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/

SQL Server 2012 Management Studio no attach option for mdf files

I am trying to attach a database to my Azure SQL using Management Studio 2012. However, there is no "Attach" option when I click on the Databases folder on the server. Could anyone make some suggestions how to attach a .mdf file ?
you cannot attach an .mdf directly to Azure SQL Database. neither can you restore a backup (.bak).
you can follow what sqluser pointed out above.
there's also other options like using Migration Wizard, bacpac, etc...
have a look here
Right click on your database ==> Tasks ==> Deploy database to SQL Azure

Restoring a MSDE database to SQL Server 2005

I am having a hard time trying to get a SQL Server 7.00.1094 backup to restore to a 9.00.1399 (MSDE to 2005) I was told that this will work. However I have done some research and all signs point to detaching and then attaching to the 2005 instance. The software provider specifically said I have to do a backup and restore, not a detach and attach. What is a good way around this? I am unable to upgrade the current instance to 2005 from 7.0.
I am able to add a new database to the 2005 instance, and restore other databases from the 7.0 instance by overwriting the new database I create, I only get this error when trying to restore the master database.
I guess the main question is, how do I successfully restore the system databases from 7.0 (7.00.1094) to 2005 (9.00.1399).
System.Data.SqlClient.SqlError: The backup of the system database on the device C:\test db run\mvdbtest cannot be restored because it was created by a different version of the server (7.00.1094) than this server (9.00.1399). (Microsoft.SqlServer.Express.Smo)
One workaround would be to download the 2000 version of MSDE, restore your database to that instance, then take a backup from 2000, and restore that backup to 2005. This is the same approach you have to take today in order to get a database from 2000 to 2012.

SQL Server 2000 / SQL Server Management Studio 2008 - How to copy a database?

I'm connecting to a SQL Server 2000 server with SQL Server Management Studio 2008 and need to make a copy of a database.
Right-Click the database and pick Copy Database brings up the nice wizard. When I pick the destination server (the same server as the source server) the wizard happily tells me I need SQL Server 2005 or better and stops.
How can I make a copy of the database? I have no access to the computer other than through the management studio. Upgrading the server is not an option that is available to me.
You'll probably need to backup the DB, then restore it with a the new name (and then get someone with access to do the clean up). This should be OK as long as you make sure that the physical file locations are updated when you choose a new db name.

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.