Converting SQL Server database to local C# database - sql

I have created program that uses SQL Server database to store data. After a while (and lots of stored data) I have realized I don't need database on the server, local database running without server could do the job.
Now I need some advice how to export, convert or whatever, SQL Server database to local (sdf) database? I'm using VS 2010 and SQL Server 2008, I also have SQL Server Management Studio.

Check out the SQL Server to SQL Server Compact Edition Copy Tool available on CodeProject in C# source code:
Should do just what you need: copy data from SQL Server to a SQL Server Compact Edition .sdf file.

Use the Export database tool? If you are using MS Windows OS then you can access is through the JET interface.

Use my Export2sqlce.exe command line utility: http://erikej.blogspot.com/2010/02/how-to-use-exportsqlce-to-migrate-from.html

Related

How to dump remote SQL Server 2005 database schema?

I want to get the schema of tables from a remote database. I only have the username and password of remote SQL Server. It doesn't provide any tools like in SQL Server Management Studio. What is the proper way for getting schema of tables from this remote sql server? please help
The 2012 SP1 version of Management Studio Express is fully functional and free. Go download it instead of trying to reinvent the wheel.

Open WebMatrix SQL Server database in Microsoft SQL Server Management studio

I have a question. I did migrate my SQL CE database to SQL Server database and now i would like to open this SQL Server database in Microsoft SQL Server Management studio. Do you knoq how can I do it?
I need more information to help you, are you having trouble determining the server or the login or what? You need to login as a user with rights on that database. Do you know the server name that it was migrated to?
If you are looking for an easy to use tool to convert between mssqlce and sqlserver try this one: http://sqlcetoolbox.codeplex.com/releases/view/69910

Transfer a database to SQL Server 2008 from SQL Server 2008 Express

Anyone know the generic practices transfer the database to SQL Server 2008 from SQL Server 2008 Express (I'm not sure it is r2), when I try to attach the .mdf file from Express, there is an error message.
the database cannot be opened because it is version 661. This server supports version 655 and earlier. A downgrade path is not
supported.
Well, the message is clear: the file you're trying to attach from Express is from a newer version of SQL Server
So it appears that you indeed have SQL Server 2008 R2 Express, and you cannot attach this to a SQL Server 2008 instance. There's no way, no hack, no workaround, no trick, or no third-party tool to achieve this - it just cannot be done - period.
So you either need to upgrade your main instance to SQL Server 2008 R2, too - or you need to find another way (like scripting out the structure and/or data into .SQL files) to move your changes from one instance to the other - or use a third-party tool like Red-Gate SQL Compare to synchronize the changes between the two instances.

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.

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.