4

I have .net script access to a microsoft server and I need to synch the database on this end with a LAMP server on the other end. Currently I've written my own CSV export routine, and a matching importer, but it's creaking under the strain. Is there a more efficient way to go about this? Can I stream a CSV export direct to IIS somehow?

I know that if I had more privileges, I could run a BACKUP DATABASE command, then run the backup to the other server with FTP and hopefully find some way to import this into MySQL. However this is not an option.

4
  • Could you explain why @ta.speot.is's proposed answer is not acceptable to you? Could you explain what privileges you do have? Commented May 15, 2012 at 16:46
  • @eggyal I have limited FTP access and the ability to upload .aspx.vb scripts. Commented May 15, 2012 at 18:59
  • And you can't link servers because...? Commented May 15, 2012 at 19:52
  • You wont be able to restore a MSSQL Backup on a MySQL system. So that thought is out of the question. You might be able to run a MySQL backup to some extent on a MSSQL backup but it will require you to edit the backup script. Commented May 17, 2012 at 9:18

5 Answers 5

5

If MySQL is accessible from the MSSQL server then you can create a linked server within MSSQL and MERGE, INSERT, UPDATE or whatever into MySQL's tables from within MSSQL.

Sign up to request clarification or add additional context in comments.

Comments

4

You can code a script that has .NET DataReaders to open cursors on MS SQL and then using another connection that is connected to MySQL insert the data row by row. You can process all the tables sequentially.

Comments

4
+25

I have done something similar. The easiest way would be to have a direct connection between your MSSQL server and MySQL server. You setup a linked server in MSSQL to the MySQL server and then use insert,update etc to do transactions to the Linked server. This is what ta.speot.is mentioned in his answer. However you dont have a direct link to the MySQL server so that option is not viable.

The other option would be to use MSSQL Service broker. With service broker you could queue individual updates, deletes and inserts to a webservice. This webservice could be hosted on IIS. The webservice would get called from the queue and then you can apply the individual transactions one at a time to the MySQL database. Service broker is a asynchronous messaging system embedded inside MSSQL 2005+. With it you can send messages to other servers, databases and even external services.

Just keep in mind the Service Broker architecture takes time to learn and implement. I have created custom replication architecture between mssql and mysql using service broker that handle 88 million plus transaction a day on a celeron laptop. It just took some serious elbow grease.

UPDATE Seems like SQL2008 allows you to run Service Brokers outside of SQL server in some way. See this link http://blogs.msdn.com/b/sql_service_broker/archive/2008/11/21/announcing-service-broker-external-activator.aspx I dont know if this might be more up your street.

4 Comments

Can you set up a service broker through .net?
No service broker is all SQL. You would need to do it on the MSSQL server.
No dice for me then. Thanks for the interesting answer though.
Could you add some detail to the question? I am sure there must be a way to help you. Just the details are on the sketchy side.
3

Instead of CSV-files generate SQL-scripts suitable to run on MySQL server

Comments

0

I dont know if this will help, but a long time ago I created a small software to do this particular task with a large dataset, here it is:

http://csvimporter.codeplex.com/

I made it open source :)

Hope it helps.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.