Please help me about this.. I use to attach a database but it has an error this is the error. And I use SQL Server 2012
Microsoft SQL Server Management Studio
Attach database failed for Server 'DANICA-PC\SQLEXPRESS'.(Microsoft.SqlServer.Smo)
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
The database 'MTS' cannot be opened because it is version 782. This server supports version 655 and earlier. A downgrade path is not supported.
Could not open new database 'MTS'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 948)
You cannot do this - you cannot attach/detach or backup/restore a database from a newer version of SQL Server (the mdf file is version 782 - this is SQL Server 2014) down to an older version (version 655 is SQL Server 2008) - the internal file structures are just too different to support backwards compatibility.
You can either get around this problem by
using the same version of SQL Server on all your machines - then you can easily backup/restore databases between instances
otherwise you can create the database scripts for both structure (tables, view, stored procedures etc.) and for contents (the actual data contained in the tables) either in SQL Server Management Studio (Tasks > Generate Scripts) or using a third-party tool
or you can use a third-party tool like Red-Gate's SQL Compare and SQL Data Compare to do "diffing" between your source and target, generate update scripts from those differences, and then execute those scripts on the target platform; this works across different SQL Server versions.
I would try scripting out the tables and data and then creating it in SQL Server 2012 so you'll have a compatible version. You are trying to attach a SQL Server 2014 database with SQL Server 2012. The database is incompatible with your SQL Server.
Related
Need Help please.
I have installed SSMS and Visual Studio.
I have 2 issues.
I am trying to learn SQL DBA and hence I installed SSMS only, I haven't installed SQL Server/Express.
While opening up a new query on SSMS, it asks me to enter the server name which I am unable to find and neither I can find instance name anywhere in my computer.
I have tried everywhere cmd and configuration manager.
Same with visual studio, when I try to create database, it doesn't allow me to add new local db as it doesn't show up when I try to add.
SQL Server is based on the client/server database system. SQL Server Management Studio is a management client, so you need a SQL Server installation in order to use it. You can install SQL Server Express for free which has a very similar feature-set to the paid editions (Standard and Enterprise Editions).
...in comparison to MS Access or SQLite which are a file-based database systems.
Visual Studio is an IDE which has some database tooling (SSDT: SQL Server Database Tools), while it can also be used for DBA tasks it is more appropriate for software development tasks using SQL Server than SSMS.
I'm trying to understanding LocalDB by reading MSDN: SQL Server 2016 Express LocalDB and MSDN: SQL Server Express LocalDB and SQL Server Express and a number of SO posts including confusion about SQL Server Express and localdb, I still cannot understand what is LocalDB. I understand and have used SQL Server Express and SQL Server CE.
Questions:
LocalDB...the necessary SQL Server infrastructure is automatically
created and started
My understanding is that, if using LocalDB to handle an application's database, neither the developer nor the client machine where the application is deployed needs to install the heavy SQL Server Express, but just need to install the lighter LocalDB. How, then, without SQL Server Express install can localDB "create(d) and start(ed)" SQL Server? If localDB
... once installed, LocalDB is an instance of SQL Server Express that can create and open SQL Server databases. The system database files for the database are stored in the users' local AppData path which is normally hidden.
If developer or client can use localDB without installing SQL Server, how can localDB be an instance of something that is not installed? Or is localDB an incomplete version of SQL Server Express that just does not need to click..click..click.. to configure. Essentially localDB works like SQL Server CE where localDB use some hidden "files" in AppData to create database while SQL Server CE use the dll to generate the database?
SqlLocalDB.msi program to install the necessary files on the computer
If client still needs to install localDB (which is not really portable along with the application like SQL Server CE), then why not just install SQL Server Express? Either localDB or SQL Server Express is above 100MB+ anyway and need separate installation, what is the point of using localDB anyway?
LocalDB is a programmer-oriented version of SQL Server Express that needs to be installed just like SQL Server Express.
Unlike SQL Server Express, it's not installed as a Windows Service that starts up with your Windows OS - but it only starts up as needed (when your application starts up, or when you start it manually with the SqlLocalDb command line tool).
But LocalDB IS SQL Server Express (not Compact Edition). It uses the same .mdf and .ldf database files like and desktop/server version of SQL Server, not SQL Server CE's .sdf file format.
We used localdb on a project where we had agents in the field using laptops.
The functionality of localdb was better than SQL Server CE (I don't remember exactly what CE was missing, but it was important to the project), you should review the functional differences.
Another advantage was the db was stored in the user folder which makes it impossible for other non-admin users of the laptop to see. This allowed us to reuse and even share laptops between users without mixing data - a nice feature.
Finally, the dbs (with a little effort) can be copied to the dev/support side and restored/attached for troubleshooting. They are full .mdf/.ldf database files.
You do have to create the instances using a command line (sqllocaldb utility), after the product is installed. This was just part of our install app.
Error -
mdf file can not be opened because it is version 655, this version
support 612 or earlier
Note :
I am created this database file using SQL Server 2005 and later that file is opened in SQL Server 2008 then automatically change version from 612 to 655.
But I currently want to open that file in SQL Server 2005.
Any solution is possible then help me.
Upgrading an mdf is a one-way process. You'll have to go back to a backup, an earlier version of the file or recreate it.
I'm guessing you don't have backups or an earlier version of the file (nobody posting "how do I get something back" on these sites knows what a backup is).
As far as recreating goes, you can attach the database to a SQL Server 2008 instance (or later) and then use SQL Server Management Studio to export the database into a blank database on an '05 instance.
From within Management Studio use the Generate Scripts Wizard. You can use this wizard to build queries that will reconstruct the database. Make sure you choose to script Schema and Data and set the destination server version as SQL Server 2005.
Alternatively, you can use the SQL Server Import and Export Wizard although it may not bring all your database objects across.
I'm very new to creating installers. This application needs to connect to a SQL Server database for it to be used. The tables of that database has rows which are needed by the application, so just reconstructing the database structure is not what is needed.
Can I just export the database as a .mdf file and connect from there?
Or do I need to install SQL Server Express on those computer as a prerequisite and attach the database from there? If so, how do I attach it on installation?
Or are there other ways to include a SQL Server database to an installer and be used by the installed app?
On the target machines you need to install SqlServer (express or standard).
You don't need any management application like Sql Server Management Studio.
Then you can attach your MDF to the database engine via connection string as this one
Server=.\SQLExpress;AttachDbFilename=c:\yourfolder\yourfile.mdf;Database=yourdatabase; Trusted_Connection=Yes;
The installation of SqlServer is not an easy task to do via custom installers.
If your application is not intended to be used outside of the local machine you could use LocalDB.
The install of this flavor of sqlserver is more easy.
Other alternative is:
Extract a sql script that rebuilds your database. (and provide a method to execute the script)
Export the data needed and execute a bulk insert to reinsert the data in the rebuilded database
I have written c# application that uses mdf file for database.when i make setup of that project and runs on other computer having dotnetframework and sql server compact 3.5 then id dose not runs and exception is shown saying something sql server not found or not ready for connection something like that what should i do
mdf is not for sql server compact edition, it is for the real sql server. You need to deploy it to Sql Server Express edition or higher.
Edit:
You can install SQL server express edition or if you want to use the sql compact server you need to create a "local database" in visual studio.
When adding a mdf-database to your visual studio project is is attached to your local sql express database server behind the scenes when you start your project.