I have data in a table in Oracle on one server that I want to copy daily to a table in SQL Server 2008 on another server.
My solution (which works nicely, but is a somewhat cumbersome solution) is as follows:
I run the following batch file on the Oracle machine
dumpdata --schema=mydb/mypassword --source-query="select * from MyTable"
MyTable >> q:\output1.sql
dumpData comes from the cx_OracleTools package, and q: is a networked drive on the SQL Server machine
I then run the following batch file on the SQL Server machine
sqlcmd -i before.sql
ssr.exe 0 "to_date(" "convert(datetime," output1.sql
ssr.exe 0 "'YYYY-MM-DD HH24:MI:SS'" "101" output1.sql
ssr.exe 0 ");" "); /SSR_NL/ GO /SSR_NL/" output1.sql
sqlcmd -i output1.sql -o error.txt
The first line runs a SQL that deletes the rows from the table in the SQL Server database. The second, third and fourth lines converts the dates into a format that SQL Server understands. The fifth line imports the lines into the SQL Server database.
Now, the dumpData routine (because it creates INSERT statements) creates huge files, so I changed the dumpData to do the following:
dumpdata --schema=mydb/mypassword --source-query="select * from MyTable
where to_char(update_date,'yyyy')='2012'" MyTable >> q:\output1.sql
Now I have an update_date field in the table, which changes whenever the row is updated. So I thought I would copy only those rows which have changed in 2012 (which is a manageable size) and import those to the SQL Server database.
However it is not enough for me to delete those rows in the SQL Server database which changed in 2012 in the SQL Server database and then do the import. I need to delete all those rows in the SQL Server Database which were changed in 2012 in the Oracle database.
If I could somehow convert my text file of INSERTS to an UPSERT (See Solutions for INSERT OR UPDATE on SQL Server) then my problem would be solved.
Alternatively, I could use SSIS 2008.
Does anyone have any simple ideas where I could tweak my existing solution to work?
Thank you...