views:

28

answers:

1

Hi folkds,

I've got a source database (Sybase), which is read-only and you can write to the database with a import file. The other side is my own database (MSSQL) which has no limitations.

The main problem is that there are no timestamps on the first database and I don't have any access to change the source database. So is there a engine/solution to get this sync. done?

A: 

A diff algorithm might work, but it wouldn't be fast, in the sense that you would have to scan the whole source database for each synchronization.

Basically you would do a full data extract, in an agreed upon, and stable, manner (ie. two such extracts with no changes between would produce identical output.)

Then you compare that to the previous extract you did, and then you can find all the changes. Something slightly more intelligent than a pure text diff would be needed, to help determine that rows weren't just deleted+inserted, but in fact updated.

Unfortunately, if there is no way to ask the source database what the latest changes are, through, as you've pointed out, lack of timestamps, or similar mechanisms, then I don't see how you can get any better than a full extract each time.

Now, I don't know Sybase that much, but in MS SQL Server you could potentially create another database that mirrors the first, and in this second database you could make whatever changes you need.

However, if you can make such a database in Sybase, and use SQL to access both at the same time, you might be able to run queries that produce the differences.

For instance, something along the lines of:

SELECT S.*
FROM sourcedb..sourcetable1 AS S
    FULL JOIN clonedb..sourcetable1 AS C
    ON S.pkvalue = C.pkvalue
WHERE S.pkvalue IS NULL OR C.pkvalue IS NULL

This would produce rows that are inserted or deleted.

To find those that changed, you would need this WHERE-clause:

WHERE S.column1 <> C.column1
   OR S.column2 <> C.column2
   OR ....

Since the tables are joined, the WHERE-clause would filter out any rows where the previous extract and the current state is different.

Now, this might not run fast either, you would have to test to make sure.

Lasse V. Karlsen
Thanks for your answer. The main problem is that I'm not able to use SQL - I've to use ADO.NET. So I've to load all data from both sides, get the changes and update the destination.
Timur Zanagar
Does data change in both servers? Or do you just want to mirror everything into a readonly database?
Lasse V. Karlsen
Yes and no ;-)The source database is read-only and destination is my database.The changes from source database have to be in the destination database. The changes from the destination database are imported as text files into the source database. So if you just see the task without the text files - yes, it's just a mirror.
Timur Zanagar