SQL to SQL CE: How to read an SQL or Access database and write it out as SQL CE database? - sql

I have just one simple table in my MS SQL database (or Microsoft Access). How do I read in this table and write it out as an SQL CE database? I have both Visual Studio and WebMatrix installed so I can use either of these tools if required. Thanks.
Is it possible to copy and paste one table to another? This would be the simplest if it works.

Try my Visual Studio add-in, allows you to migrate from SQL Server to SQL Server Compact: http://sqlcetoolbox.codeplex.com - command line walkthrough here: http://erikej.blogspot.com/2010/02/how-to-use-exportsqlce-to-migrate-from.html

You can download a free copy SQL Express Management Studio (SSMS).
SSMS has the ability to connect to both full blown SQL, SQL Express, and SQL CE databases.
Within SSMS you can right click on the table and use the wizard to move data back and forth. Or create scripts that will generate the raw table structures that exist in MS SQL, SQL Express and allow you to move them to SQL CE.
The primary wizard you'll probably use in SSMS to move data from an Access table to a SQL, or SQL CE table is called SQL Server Import/Export Wizard.
The learning curve on these wizards is pretty minimal. As your needs grow more advanced and the things you want to do get a little more fancy you'll find that scripting and the tsql language is where you'll want to dedicate some time to learning. But this should get you started with the question at hand.

Related

How to cope with SQL Server 2012 vs SQL (Azure) Database sql files

I'm trying to port my system to SQL Database (Azure instance) from SQL Server 2012.
I'm using Visual Studio 2013 and I have my .sqlproj with all the definition of my database inside.
Given that a number of SQL statements are not available in SQL Database (like "ON [PRIMARY]", filegroups, etc.), I should change a huge number of *.index.sql , *.pkey.sql, *.table.sql files.
Unfortunately I still need to cope with SQL Server 2012 installations (some customers are still on that infrastructure), so I would like to have instead a simple way to switch between the "SQLAzure" vs. "OLD-2012" syntax.
E.g. something like Compilation Symbols would be useful, or similar tricks.
Anyone has a brilliant idea on how to manage such an issue?
Thank you very much!
cghersi
You could use a migration tool like Sql Azure Migration Wizard (not an official tool, but really good) and then generate the *.sql scripts that are used on SQL Database (SQL Azure). Then you can create a new project that only has those files when you target SQL Database (SQL Azure).

Cant edit schema or data from sql server management studio

I have connected to my SQL azure server using SQL Server 2012 Management Studio and I cannot edit any of my table's schema or the data in it. When I right click on the table the options are missing. Am I doing something wrong?
Not that I am using SSMS 2012, but in 2008 R2 is generally the same. There is no GUI for neither table designer, nor "Edit top 200 records". You have to begin diving into the DDL and DML for SQL Server and give up GUIs. One way you could use GUI to some extend, especially for DDL is to use the portal provided Windows Azure SQL Database manager. You can find a link to it when you go to your database from either the new or the old portal (Manage). Other way is to use some third party tool, which I am not aware of.
Here is the link to that manager from the new portal:
Another option some people may find helpful, if you have and use Visual Studio then you can link to the server in ServerManager, connect to the database, and then design and edit data directly.
My 2008 R2 version of SSMS had the same problem. I downloaded 2016 CTP3 SSMS which has Azure support and everything is normal for the Azure Databases.
https://msdn.microsoft.com/en-us/library/mt238290.aspx
I did lose my connection history information so beware.

Migrate from Windows 2008 SQL Server to SQL CE (for WebMatrix)

I have some stuff in my remote SQL Server 2008 DB. I want to put it inside my SDF database (the WebMatrix one). But I can't just copy the rows from Navicat (while viewing table for SQL Server 08) into the SDF database because some rows don't let you manually insert stuff.
So I need a way to "Migrate" from Windows SQL Server 2008 to SQL Server CE (.sdf).
I think I have the right tools to accomplish this, but would appreciate it if someone can point me in the right direction.
I have:
Visual Studio 2012 Ultimate RC
Web Matrix
Navicat Premium
Well, after hours of searching, I've managed to solve this issue.
How to Migrate/Downsize a SQL Server database to SQL Server Compact 4.0 (and 3.5) has an extremely straightforward approach to doing this.
Like myself, you may need to download the following tools (and place them in the same directory as your CMD.exe file:
SQL Compact Command Line Tool
SQL Compact data and schema script utility

Creating SQL statements for creating tables in SQLce database

I'm starting to learn database, and I will work with SQLce. Is there some type of library that can assist in creating the proper SQL statements for creating tables etc? (Not for query of the database, as I plan to use LINQ). I'm not thinking an MS library, but some amateur project maybe..
You want to download SQL Server Management Studio Express. The SSMS tools let you connect to SQL CE as well as the full blown SQL Server databases, and best of all it's free. You can create your tables via the GUI, and then instead of saving the table, you could have it show you the SQL script instead and learn that way. Everything you do in the GUI executes T-SQL behind the scenes and you have the option of saving all that SQL and running it yourself.
See this stackoverflow question here too for some more details.

Restore SQL Server 2008 DB *to* SQL Server 2005

Got myself in a bit of a pickle here ... working on a CMS project, under the assumption that sql server 2008 was greenlighted as the db of choice. Well it wasn't, we now have to backport all of our content out SQL Server 2008 and into SQL Server 2005.
A simple backup/restore procedure yields: "RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3241)".
Unfortunately, exporting the data to an excel spreadsheet yields multiple OLE errors which I believe is actually a problem in the db of the cms.
Does anyone out there have other approaches they would like to recommend for this task? Thanks in advance
Use RedGate:
tool for comparing and deploying SQL Server database contents.
You can work with live databases, backups, or SQL scripts in source control. Damaged or missing data can be restored to a single row, without the need for a full database recovery.
SQL Data Compare helps you compare and deploy changes quickly, simply, and with zero errors...
There is no way to do this by default. You can generate scripts for 2008 database on 2008 server and then execute these scripts on 2005 version. Note that you’ll have to manually review scripts and remove all parts that are unique to 2008 version.
Another way is to use third party tools such as Red Gate or ApexSQL Diff (move schema) and ApexSQL Data Diff (move data).
Use the Generate SCripts to create the database and schema and ensure you target SQL Server 2005 and script data.
Rather than do a backup and restore you might try using SQL 2005's Import/Export Data wizard.
http://support.microsoft.com/default.aspx?scid=kb;en-us;314546
http://msdn.microsoft.com/en-us/library/ms140052(SQL.90).aspx
I've just hit the same problem and here is how I worked around it.
The problem was to copy a database from an operational SQL Server 2008 database to a new SQL Server 2005 database.
I scripted the database using Management Studio on the 2008 server. I only scripted the database design, not the data. I should add also that the DB only has tables and indexes, so I haven't tried this with any cleverer objects although I can't think why they wouldn't work.
On the 2005 server I created a new database by hand and then ran the script to set up all the tables and indexes.
The in Management Studio back on the 2008 server I used the Export Data wizard to export the data from the 2008 server to the 2005 server. It's currently running and seems quite happy moving the data.
Once all the data is across I'll have a couple of small things left to do - create the users and set-up the security in the 2005 DB, but all-in-all it doesn't look like a bad way of doing it. It's not quite point-and-click but it's not too strenuous.
So it seems that the Copy Database wizard won't work (I think because the package ultimately runs on the 2005 server and 2005 Management Studio can't talk to 2008) but the Export Data wizard is quite happy moving data ... as long as the DB already exists on the target server.
Hope that's useful.
It's not possible to restore to previous versions in SQL Server
Is there no SQL 2005 backup around? Otherwise you really are limited to export the entire database in 2008, and re-import back into 2005, or the Import/Export wizard in 2008
Or rely on 3rd party tools. e.g. Red Gate Data Compare is able to sync. the DATA between 2 servers/databases
I only use mysql but can you export your data into sql statments, and then import then into sql2005? Just a thought..
I faced a similar problem (sql 2005 to sql 2000), and found that I happened to have a blank database at the older version. I used bcp.exe to copy all the data.
check this link click here
You can create the database script in sql server 2008 and you can use it sql server 2005 and lower version....