importing data from one database to other when schemas are different - sql

I have this SQL Server 2005 DB and we are upgrading to a new DB in SQL Server 2008. The schemas would be slightly different between the databases. What would be a best option to copy data from the old DB to the new DB.

Define "slightly different". Integration Service is probably the way to go.

Since the schemas are only slightly different, I would suggest making a full backup of the SQL2005 DB and restoring it on the SQL2008 server. Once you have the direct copy, use a script to migrate the data on the few tables where the schema is different.
It really depends on the definition of slightly.

Use Integration Service to design a whole package, or you can connect to the 2005 instance from within 2008 SSMS and right click on the tables and select "Import Data". This will bring up an Wizard that will do the work for you (through SSIS) and let you copy the data right over.
Another option is to use SQL Server Data Tools, which is a new tool from MS that has a schema compare tool where you can actually generate the scripts to create the tables and related objects.
http://msdn.microsoft.com/en-us/data/gg427686

Related

Restoring Database without data

I have a backup of a very big database.
What I want is to restore this database, but there is not enough space on my harddisk. Since I don't need the data, is there a way to restore it without the data?
I've already tried to script the schema etc. but when I run the script, it doesn't work unfortunately.
Thanks in advance
Use the Generate and Publish Scripts Wizard to create a Transact-SQL script for many objects. The wizard generates a script of all the objects in a database, or a subset of the objects that you select. The wizard has many options for your scripts, such as whether to include permissions, collation, constraints, and so on.
check here how to generate script-
SQL Server 2012 copy database without data
Do you have RedGate SQL Compare? If I only had a database backup available, I would run SQL Compare using the backup as source, and a brand new database as the target. The results of the compare should give you what you need, in the correct order of deployment.

Create a copy of a DB that is blank then import data from another DB

I have 2 databases I need to work with.
Database A (DBA) = the clients database that is far too outdated to be used with my current data structure.
Database B (DBB) = my current development database
What I need, is to find a way to create a blank database that is structured as DBB, schemas, tables, triggers, everything, and then import data from DBA.
I have the Red Gate SQL Compare/Datacompare and SQL Management Tool available to me.
Is what I am trying to achieve possible with what I have or possible in general?
Normally I have scripts to update the DB going up a version at a time, but DBA is so far behind on the updates, I do not have access to those scripts anymore.
I am using SQL Server 2005.
I'm not familiar with RedGate stuff but you could do the Generate Scripts task (right click a database in SSMS) on both. Select Schema Only for DBA then Data Only for DBB in the Advanced Options.

Oracle 11g Script database with data

Is there a way in Oracle 11g to dump database to sql script, that when run will perform database, users, tables and data creation?
In Microsoft SQL Server there's SSMS Toolpack that is capable of such thing. (Script all data from SQL Server database) I'm interested whether the same is possible in Oracle 11g.
To extract metadata and data you should look at data pump, specifically the export and import tools. This will be the simplest, fastest and most supported way to move everything.
You will need to already have created the database, but I'm not sure if you're confusing that with the Oracle schema. Which you will also have to create in advance by creating the user(s) that will own all the objects. You can extract a script to create the user/schema, e.g. from Toad or SQL Developer, or using the DBMS_METADATA package.
Most client applications also have options to export pretty much everything as scripts. In SQL Developer, for example, go to the Tools menu and there's an 'Export database' option where you can choose what you want to include, which will be pretty much everything in your case. You'll still need to pre-create the new database to run those scripts against.

Sql Azure Sync Dataset not supporting custom DataType of the tables while try to sync, is there any workaround for that?

The On-premises Database have tables and those tables columns types are UDTs, for this reason created same UDTs and tables using these UDTs on the cloud.
But when trying to syncing them its shows error not supporting UDTs, So am I missing something or is there any workaround to do syncing with UDTs?
Here if SQL Azure allows to create UDTs & also allows to create tables using those datatypes, then why not allow to sync?
FYI "SQL Azure" is called now "SQL Database" so if you find reference to Windows Azure "SQL Database" you can consider applied to your requirement as well.
SQL Database does not support user-defined data types, extended properties, Windows authentication, or the USE statement.
However the November 2010 update to SQL Server 2008 R2 includes support for SQL Database. The Generate Scripts Wizard now allows you to script for database version SQL Database so the scripts generated are directly compatible to be executed on SQL Database. The scripts thus generated are compatible with SQL Database and can be compiled on SQL Database without any further modifications. So your UDDT or custom data types can my transferred to SQL Database through this migration script.
If your Database is pre-SQL Server 2008, you can use the "Schema Migration with pre-SQL Server 2008 R2" section from this article.
unfortunately, there is no workaround at this time. The Data Sync Service is largely based on Sync Framework and it doesn't support UDT as well. The Data Sync Service supports spatial data types in the latest release though.

Keeping database structure compatible between MS-Access and SQL Server

I'm working on a legacy project, written for the most part in Delphi 5 before it was upgraded to Delphi 2007. A lot has changed after this upgrade, except the database that's underneath. It still uses MS-Access for data storage.
Now we want to support SQL Server as an alternate database. Still just for single-user situations, although multi-user support will be a feature for the future. And although there won't be many migration problems (see below) when it needs to use a different database, keeping two database structures synchronized is a bit of a problem.
If I would create an SQL script to generate the SQL Server database then I would need a second script to keep the Access database up-to-date too. They don't speak the same dialect. (At least, not for our purposes.) So I need a way to maintain the database structure in a simple way, making sure it can generate both a valid SQL Server database as an Access database. I could write my own tool where I store the database structure inside an XML file, which combined with some smart code and ADOX would generate both database types.
But isn't there already a good tool that can do this?
Note: the application also uses ADO and all queries are just simple select statements. Although it has 50+ tables, there's one root "Document" table and the user selects one of the "documents" in this table. It then collects all records from all tables that are related to this document record and stores them in an in-memory structure. When the user saves the data, it just writes the document record and all changed data back to the database again. Basically, this read/write mechanism of documents is the only database interaction in the whole application. So using a different database is not a big problem.
We will drop the MS-Access database in the future but for now we have 4000 customers using this application. We first need to make sure the whole thing works with SQL Server and we need to continue to maintain the current code. As a result, we will have to support both databases for at least a year.
Take a look at the DB Explorer, there is a trial download too.
OR
Use migration wizard from MS Access to SQL Server
After development in Access (schema changes), use the wizard again.
Use a tool to compare SQL Server schemata.