views:

59

answers:

5

We are migrating a client's own database schema to our own (both SQL-Server). Most of the mappings from their schema to ours have been indentified and rules been agreed on if the columns don't exactly align (default values etc.)

Previously, depending on who was assigned the task, this has been done either with a mixture of sql scripts or one-off vb apps.

I was thinking there must be a application (commercial or otherwise) where you can assign these mappings/rules and have it stream the data across. Surely the setting up and configuration of this tool would be less than the creation of ad-hoc scripts...

Is there an app? Apart from the obvious 'be careful' any tips to mitigate the stress of a non-DBA porting one schema to another?

A: 

Not really. Problem is that whatever app you would have would be more a frameowrk anyway. Schema transfers, by definition, are partially tricky to do. And a tool doing half of the stuff is nearly useless - that is easy to do in SQL anyway ;)

TomTom
A: 

I do this sort of thing every day. because of the custom nature of our software, i usually one-off the whole thing. about 70% of the time, i use ms access as an intermediary (the rest of the time, i write code to do it). i load the source data into ms access, massage it and then move it into our sql server tables. access is very well suited for this type of work. the main thing to be careful about is your keys and duplicate restrictions. i'm sure there are off-the-shelf apps to do data migration, for my use, however, i need more control and ms access allows me to reuse some portions of the data import while maintaining the ability to customize everything.

best regards, don

Don Dickinson
+1  A: 

You can use database migrations in your code.

There are several .net data migration libraries that were inspired by ruby migrations. They define database changes in code.

Migrations allows a developer to manage rollout, and rollback, of database schema changes in a controlled and consistent manner.

Look at these:

Oded
Do most of these support massive changes in schema? None of the tables names map (eg: we have a prefix on all ours), differing field names (some are pluralised, some aren't).
graham.reeds
You pretty much define an `up` and `down` script for changes - it will be as comprehensive as you make it. They will not change a column name deep in a stored procedure automatically, if that's the question.
Oded
RikMigrations (despite the name) seems like the best choice listed.
graham.reeds
No stored procedures - just hooking data from one schema to a vastly different ones, and to be able to specify defaults where needed and maybe do some calculations (N/E to Lat/Lon, etc).
graham.reeds
@graham.reeds - Sorry, I don't know about very large migrations, never have had them myself, though in principal they should work.
Oded
@Oded - Looking closely at RikMigrations: I can't see how to map A.LOGINNAME to b.user_name.
graham.reeds
@graham.reeds - I never used RikMigrations myself. I mentioned it for completeness sake. Possibly a topic for another question?
Oded
@Oded - Could you tell me how to perform that task in one you have used? That's what I need to do so any product that can do it will get my vote.
graham.reeds
@graham.reeds - perhaps migrations are not as suited to your situation as I thought. They are more about incrementally building the schema together with your DB. Take a look at tools like SQL compare.
Oded
+1  A: 

I use an Open Source ETL (extract/transform/load) tool called Talend Open Studio for tasks like this.

In short, Talend Open Studio (TOS) is a GUI code-generation tool, in which you plug in different components to import, munge, and export data--and the resulting code is portable Java or Perl. There are plenty of components to help you make decisions about non-standard data (or you could always add your own Java or Perl routines for the most complex parts).

TOS has proved to be well worth the time I initially invested in it... so I would definitely recommend it.

ewall
Hmmm. We are a Microsoft shop so java/perl would probably be a bit hard to fly.
graham.reeds
My company is also very Microsoft-centric... but these days it's nigh impossible to avoid some Java used somewhere. In our case, it's very easy to run the JAR from Talend with a java.exe command-line, even from our Windows-based job control software. But YMMV, of course ;)
ewall
A: 

Try SQL Data Examiner. This tool allows comparing/synchronizing sql-query results, so you can write appropriate queries to both databases and compare/synchronize results returned by these queries.

SQLDev