SQL Server 2000 database after restore to 2005 is empty - sql

I have very old backup file (.bak) of SQL Server 2000. After restoring it to SQL Server 2005, the database looks empty (please see screenshot).
What is the probable cause?
screenshot

Answer for other people looking for solution:
It turns out that the database was even older than SQL2000. It was from SQL 6.5 (1996).
From previous screenshot 6.5 means database compatibility version 65 (SQL Server version 6.5. All versions described here:
https://en.wikipedia.org/wiki/History_of_Microsoft_SQL_Server
So I had to open SQL Enterprise manager 8.0 (which supports such an old database, version 65) and change compatibility level of the database to 80 (highest available, and that's compatibility version of SQL 2000). Than make a backup of DB and restore it in SQL Server 2000-2008 as lvl 80 is supported by them. Please see screenshot below:
Compatibility lvl
And you can repeat the steps so for example DB restored in SQL Server 2008 can be changed (compatibility lvl) to a 100. Back it up again and restore in SQL 2017 or higher, you can easily find compatibility level tables:
MICROSOFT WEBSITE COMPATIBILITY LEVEL

Related

Does SQL Server database compatibility level negate SQL Server version compatibility

For instance I have an application that says it supports SQL Server 2005 to SQL Server 2008. If I transfer that database to a SQL Server 2017 machine and set the compatibility mode to 2008, should it behave just the same as if it were really on a SQL Server 2008 box? I know that the compatibility mode does limit the feature set and behaviors to what would be present in SQL Server 2008. So part of me thinks this should work just fine. But another part of me wonders if there may be others things that I am not considering that could potentially be an issue. Does anyone have any experience where this has come back to bite you?
"Upgrade the database to a SQL 2017 server and set the compatibility
mode to 2008 should it behave just the same as if it were really on a
SQL 2008 server"
Yes this is correct.
This also happens to be Microsoft's recommended upgrade process. As per Microsoft, upgrade to the latest version off SQL Server but keep the source database compatability level.
If a full database backup was taken on a older version of SQL server but restore was done on a new version, then the database compatability level is the same as old version unless its not supported on new version. In that case the database compatability level will switch to the lowest supported.
More here and here

Supported versions in SQL Server 2014?

Does SQL Server 2014 support lower versions of databases? Can I open and modify a database created by a lower version of SQL Server?
You can restore and/or attach a database from a lower version of SQL Server (2005 or newer - 2000 no longer supported) to SQL Server 2014 - yes, no problem.
But once it has been attached/restored, it becomes a SQL Server 2014 database - the internal file structures of the .mdf and other files are upgraded to SQL Server 2014 level, and you can never "go back" (e.g. you cannot backup from SQL Server 2014 and then restore in earlier versions)

how to attach .mdf file to sql server 2008 EXPRESS

I have .mdf files created using SQL SERVER management studio in another computer and wish to attach the same to SQL SERVER 2008 EXPRESS in another computer. How should I do so?
I tried this method :How to: Attach a Database File to SQL Server Express
but then it shows an error that the database cannot be created due to compatibility issues.
Msg 948: The database xyz cannot be opened because it is version 706.
This server supports version 655 and earlier. A downward path is not
supported..
....
This basically means your SQL versions don't match. For example, if you backup a database on SQL 2012, you can't restore it to 2008. In your case Version 706 is a database file from Sql Server 2012 and Version 663 is a database file from Sql Server 2008R2 (with some SP).
You can either install SQL Express 2012 to attach the MDF, or if you can't do that, you would have to script out your schema and data and create the DB from scratch.. Unfortunately there's no way to 'downgrade' and MDF back to an older version of SQL.
The message is very clear:
The database MDF file is version 706. Your server understands version 655 . Which means, despite to your claim to the contrary, that you are connected to a SQL Server 2008.
Install a SQL Server 2012, connect to it, and attach your database.
Please pay attention during the installation process to the instance name you choose and make sure you connect to that instance.
You can also check now what instances you have installed, look at what services you have on your system.
SELECT ##VERSION AS 'SQL Server Version'

Error: Can't attach DB to SQL Server 2012

I have SQL Server 2012 and I'm trying to attach a db which was previously used with SQL Server 2012, surprisingly I'm getting the following error:
The database 'DatabaseName' cannot be opened because it is version
706. This server supports version 622 and earlier. A downgrade path is not supported.
I don't really understand how this could happen since like I said it was used with same 2012 version. What am I doing wrong? How can I make it work? Please explain in detail how this can be resolved.
Thank you!!
The error sounds like the server you are trying to attach the database to is not SQL Server 2012. This may be the version of Management Studio / Management Studio Express you're using, but I suspect SELECT ##VERSION; will tell you something different. It may just be a connection string mixup if you have multiple instances of SQL Server installed, otherwise you should download and install SQL Server 2012 Express from here.
#source
It sounds like you had the following configuration and source databases:
SQL Server 2008 SP3 (ver 10.0...) - database engine
SQL Server Management Studio 2012 (ver 11.0...) - management tools
a database that was created with SQL Server 2012 (version 706)
As mentioned you could install SSMS for SQL Server 2008 (after you uninstall SSMS for SQL Server 2012). Then you would have to script your database for that version and re-run the script via 'Tasks>Script...', remembering to set the target server version as shown below.
After scripting you can then use the import/export wizard to export and then inport the data into the new (downgraded database), assuming the database had no 2012-only datatypes (such as sequences).
Another consideration is database compatibility level as shown below. You can have a SQL Server 2012 instance which hosts databases with various compatibility levels.
Using SELECT ##VERSION works very well for me. Your Database Engine is connected to a 2008 DB which certainly doesn't allow you to attach. Once I change my Database Engine to connect to 2012 DB, it works for me.
Check your Database Engine connection. You can be working on 2012 Management Studio yet connecting to 2008 DB. This is what happened to me and I have solved it use SELECT ##VERSION.

How can I attach a database?

When I want to attach database, an error occurs:
The database 'Almizan' cannot be opened because it is version 661.
This server supports version 655 and earlier. A downgrade path is not supported.
Could not open new database 'Almizan'. CREATE DATABASE is aborted.
(.Net SqlClient Data Provider)
Help me to attach this database.
Install SQL Server 2008 EXPRESS R2. There is a bug in the Web Platform Installer and it still thinks EXPRESS R1 is the latest version.
SQL Server 2008 databases are version 655. SQL Server 2008 R2 databases are 661. You are trying to attach an 2008 R2 database (v. 661) to an 2008 instance and this is not supported. Once the database has been upgraded to an 2008 R2 version, it cannot be downgraded. You'll have to either upgrade your 2008 SP2 instance to R2, or you have to copy out the data in that database into an 2008 database (eg using the data migration wizard, or something equivalent).
The message is misleading, to say the least, it says 662 because SQL Server 2008 SP2 does support 662 as a database version, this is when 15000 partitions are enabled in the database, see Support for 15000 Partitions.docx. Enabling the support bumps the DB version to 662, disabling it moves it back to 655. But SQL Server 2008 SP2 does not support 661 (the R2 version).
Think you need to upgrade the SQL Server 2008 instance (655) your trying to attach the database in, to SQL Server 2008 R2 (661), the version the database was actually created in.
See SQL Server: Attach incorrect version 661
The this answer on the MSDN seems to tell us the obvious
http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/01ed3b1c-6f29-4518-a3a4-e4e35decc05f/
When you attached the database to SQL Server 2008 to compress it the
database has automatically been upgraded from SQL 2005 to to SQL
Server 2008 from the disk structucture point of view. An internal
upgrade script has been run and has modified the on-disk structure of
the database to that new version. This can be seen at the version 655.
Once this has been done you can no longer attach the upgraded database
to a lower version of SQL Server, it will fail with the error you've
seen.
This has nothing to do with the compatiblity level of the database.
The compatabilty level only prevents the engine from using some of the
new features.
In order to get the database on SQL Server 2005 again you will need to
create the database freshly and export/import the data, for example by
using the Export/Import Wizard.
Ulrike - MSFT