Getting error while restoring backup file on SQL Server 2012 - sql-server

I have a compatibility issue when I try to restore the database backup which is taken on SQL Server 2014. But I have SQL Server 2012. Please help me to solve this problem.
Below is the error message

Best way is to Generate a script file and execute it in required server.
While generating Select Your Server version Sql2012

You cannot downgrade a backup. It is not possible.

Restoring backup taken on higher versions and restoring it to lower versions is not possible. you need to script out tables and run them on 2012, you also should account for any 2014 features which might not run on 2012..
below are the steps
right click database ->tasks->generate scripts
select entire database
in next step,click advanced and change below properties
finally save
you also can use export data like below

Related

Possible to RESTORE older version MS-SQL database onto SQL server 2017 without it updating?

I am successfully doing a daily restore of a backup from an earlier version onto MS SQL 2017 using T-SQL.
However during the restore the database gets upgraded to the current version.
This is a problem as I wish to modify the database and then do a backup which then gets transferred and restored to another system which is using the same earlier version of MS SQL.
Is it possible to run the RESTORE without the database getting upgraded?
Have been looking through T-SQL documentation and not found this referred to.
The T-SQL code I am using is:
USE master
GO
ALTER DATABASE Polly SET SINGLE_USER
with ROLLBACK IMMEDIATE
GO
RESTORE DATABASE Polly FROM DISK = 'C:\data\Polly.bak';
GO
USE Polly
DELETE FROM SytLog;
GO
ALTER DATABASE Polly SET MULTI_USER
GO
If anyone has general improvements to above I am happy for suggestions.
When the above runs I get:
Database 'Polly' running the upgrade step from version 782 to version 801.
...
Database 'Polly' running the upgrade step from version 868 to version 869.
Would like to see no upgrade steps, but only if database still usable.
When the above runs I get: Database 'Polly' running the upgrade step
from version 782 to version 801. ... Database 'Polly' running the
upgrade step from version 868 to version 869.
Would like to see no upgrade steps, but only if database still usable.
This is not possible. Every version of SQL Server has its data and log files structure that differs between server versions. And if you restore or attach database from lower version db files are one-way updated to have a structure that the current version of SQL Server needs.
It's impossible to not upgrade because the current version of server needs that new structure for db files.
All speculations around compatibility level / read_only property will not help at all, current server will never run with files that are not of the structure it needs.
In case of readonly database its files will be upgrade but the database will remain readonly.
Compatibility level has nothing to do with database version (version of db files) at all. It just tell to server what version of query optimizer should be used, what legacy syntax can still be parsed, etc.
No, this isn't possible. Once a database is attached to a newer version of SQL Server, you can't move it back to older. The only option in this case is to export/import the data. If you need to modify the database and move it back to the older server, you need to install a server with the same old version and do the restores there!
Microsoft documentation states:
If you restore a SQL Server 2005 (9.x) or higher database to SQL Server 2017, the database is automatically upgraded.
Although I would try in case of desperate need to create read-only database and restore it.
But this is kind of black magic not directly supported by vendor.
The compatibility level is important.
Even when the compatibility level of the database needs to be changed, under certain conditions the backup can’t be simply restored.
Restoring a database backup created on a SQL Server 2008
R2 to a SQL Server 2012 instance goes smoothly, but if a SQL Server
2000 backup is tried to be restored on a SQL Server 2012 you cannot
directly do it.

How to restore SQL Server 2014 database to SQL Server Express 2012

When I try to restored DB , every time I am getting this error
TITLE: Microsoft SQL Server Management Studio ------------------------------ Restore of database 'PramodDb' failed.
(Microsoft.SqlServer.Management.RelationalEngineTasks)
------------------------------ ADDITIONAL INFORMATION: System.Data.SqlClient.SqlError: The database was backed up on a server
running version 12.00.4100. That version is incompatible with this
server, which is running version 11.00.6020. Either restore the
database on a server that supports the backup, or use a backup that is
compatible with this server. (Microsoft.SqlServer.SmoExtented)
Please help me.
Like always it helps to read the error. Let me quote pretty much all of your error message:
The database was backed up on a server running version 12.00.4100. That
version is incompatible with this server, which is running version 11.00.6020.
Either restore the database on a server that supports the backup, or use a
backup that is compatible with this server.
General rule: No downgrade. On top, restoring on express is generally possibly problematic due to the limitations of the express version.
So, you need to either export/script import the database, or grab yourself and install the free developer version. Ever since they made this one free there is no excuse for even the most junior developer not to work against it.
The answer you cannot do that. You cannot downgrade a database.
As far as the work around is concerned you need to use the Import/Export wizards in SSMS to make it working.
You can't, but...
You can try Scripting your 2014 database and execute the Scripts on a blank 2012 database.
To open the Generate and Publish Scripts Wizard: In Object Explorer, expand Databases, right-click a database, point to Tasks, and then click Generate Scripts. Follow the steps in the Wizard to script all database's objects.
Note the disk space required.
You can script schema and data. See the following article:
https://www.mssqltips.com/sqlservertip/2810/how-to-migrate-a-sql-server-database-to-a-lower-version/

Adventureworks restore failed

I've just installed MS SQL Server Express 2014 and SQL Server Management Studio 2014 under Windows 10. I'm following the official Microsoft tutorial on database fundamentals, which uses the Adventureworks DW2008 database. I have tried to restore this dB using the Restore GUI, but it fails every time, as shown here:
AdventureWorks restore failure
I have verified the backup media, but it still fails. I have also restored a different dB, and that worked fine, so I know I am following the correct procedure. I have the file (AdventureworksDW2008Big.bak) in the following location:
C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\Backup
Yes, I have thoroughly researched this, but still apologies if there is already an answer on here - I couldn't find it.
The DW in the filename is for Data Warehouse and only works on that edition of SQL Server. As you only installed SQL Express you cannot use it.
Why not try Adventure Works 2014 Full Database Backup.zip instead. If you really need 2008/R2 try the none-DW from here:
AdventureWorks2008R2_Database.zip
AdventureWorks2008_Database.zip
I do not know if it will solve your problem or not,
but I had same problem. I mean I am using SQL SERVER 2017 and I wanted to restore AdventureWorks2012.
I received restore failed error, and I decided to restore AdventureWorks2017. my queries on AdventureWorks2012 in an older system in university led to the same results as my queries in AdventureWorks2017 in my system. if you are using a version of SQL SERVER and trying to restore an older or another version of AdventureWorks, you can try the same way.
I mean restoring a version of AdventureWorks which is the same as the version of your SQL SERVER.
Best to run SSMS as an administrator to avoid access denied errors (do this by right click on SSMS and choose More -> administrator)
copy adventureworksxx.bak into the sql server DATA directory where by
default all databases are usually located. ( Note: if it is in other directory
the restore may not find it OR may cause errors later)
Restore the database

How to restore SQL Server 2014 backup in SQL Server 2008

Were there any changes in this area with SQL Server 2014? I’ve seen this post Is it possible to restore Sql Server 2008 backup in sql server 2005 and I know that this was not possible as a scenario for 2012 -> 2008 but I wonder if MS made any changes here with the 2014 version.
We are evaluating 2014 version and we have a fairly large database in testing. We’d like to restore a backup of that database to SQL Server 2008 because that physical machine has more space, RAM,…
I’m getting standard error message when I try to restore backup but I was wondering if there is something else in SQL Server 2014 that I might be missing.
No, it is not possible. Stack Overflow wants me to answer with a longer answer, so I will say no again.
Documentation: https://learn.microsoft.com/en-us/sql/t-sql/statements/backup-transact-sql#compatibility
Backups that are created by more recent version of SQL Server cannot
be restored in earlier versions of SQL Server.
Not really as far as I know but here are couple things you can try.
Third party tools: Create empty database on 2008 instance and use third party tools such as ApexSQL Diff and Data Diff to synchronize schema and tables.
Just use these (or any other on the market such as Red Gate, Idera, Dev Art, there are many similar) in trial mode to get the job done.
Generate scripts: Go to Tasks -> Generate Scripts, select option to script the data too and execute it on 2008 instance. Works just fine but note that script order is something you must be careful about. By default scripts are not ordered to take dependencies into account.
It is a pretty old post, but I just had to do it today. I just right-clicked database from SQL2014 and selected Export Data option and that helped me to move data to SQL2012.
Pretty old question... but I had the same problem today and solved with script, a little bit slow and complex but worked. I did this:
Let's start from the source DB (SQL 2014) right click on the database you would like to backup -> Generate Scripts -> "Script entire database and all database objet" (or u can select only some table if u want) -> the most important step is in the "Set Scripting Options" tab, here you have to click on "Advanced" and look for the option "Script for Server version" and in my case I could select everything from SQL 2005, also pay attention to the option "Types of data to script" I advice "Schema and data" and also Script Triggers and Script Full-text Indexes (if you need, it's false by default) and finally click ok and next. Should look like this:
Now transfer your generated script into your SQL 2008, open it and last Important Step:
You must change mdf and ldf location!!
That's all folks, happy F5!! :D
No I guess you cannot restore the databases from higher version to lower version , you can make data flow b/w them i,e you can scriptout.
http://www.mssqltips.com/sqlservertip/2810/how-to-migrate-a-sql-server-database-to-a-lower-version/
Please use SQL Server Data Tools from SQL Server Integration Services (Transfer Database Task) as here: https://stackoverflow.com/a/27777823/2127493
If you have both versions you can create a merge replication from new to old. Create a merge publication on your newer sql server and a subscription on the older version. After initializing the subscription you can create a backup of the database with the same structure and the same content but in an older version and restore it on your old target server.
You can use this method also with sql server 2016 to target 2014, 2012 or 2008.

Can an MS SQL 2005 backup be restored onto an instance of MS SQL 2008?

Is it possible to restore a backup of a SQL Server 2005 database onto an instance of SQL Server 2008?
I need to rebuild a server as it's getting rather crufty, so I plan to take this opportunity to upgrade to SQL 2008 and wondered if I'll be able to restore my backups OK.
Upgrading from 2005 to 2008 is OK, moving back might require more work
N.B. You might have a problem with your database the logins (as they will not exist in the new server master db) but that's something which would happen regardless of the server version. Just re-create them and re-associate with your database.
Yes, but make sure that ALL of your servers are SQL 2008. If you have development, test, QA or disaster recovery servers, all of them will need to be 2008, since 2005 servers won't be able to restore a 2008 backup.
To prevent the lost-login problem that Ilya mentioned, follow the steps in this knowledge base article. SP_Help_Revlogin will script out your logins, and you can apply that script on the new server. Presto, all your logins are back with the same SIDs and everything.
http://support.microsoft.com/kb/246133
(And just for future reference, this is how we upgraded StackOverflow last night, heh.)
http://twitter.com/SuperDalgas/status/976719756
You can restore the 2005 backup with 2008 without any problems. The compatibility from this point of view is nice.
Backward is not possible only with backup files.
In any case you can also recreate the database structure and use SSIS to transfer data from one server to another.
You can also do a detach/attach with the database files (leastways you could going from 2000 to 2005), but there are more caveats with this approach (requires explicit rebuild indexes afterwards IRRC)

Resources