views:

33

answers:

2

I have been tasked with converting a SQL Server database into a MySQL 5.* database. I feel well-read up about converting between datatypes.

However, I read that MySQL does ANSI, not T-SQL, and doesn't support cursors. My question is, what am I supposed to do with all of my SQL Server functions and sprocs (some of which use cursors) ?

I want to "do it the right way" .

Do I move them all to code like SqlCommand cmd = new SqlCommand("SELECT * FROM ...", con");, do I move them to MySQL's procedure-things, should I try jQuery, or LINQ, or ... ?

The front end will be in ASP.NET still, but there is a possibility we might rewrite/move it to PHP.

+1  A: 

I don't think jQuery is going to help, but you may be able to do without the SPROCS entirely if you move to LINQ. Since I started using LINQ as my (lightweight) ORM, I rarely use an SPROC.

tvanfosson
I have some nasty nasty queries for certain reporting applications - a single T-SQL select statement for these can be over a hundred lines long! Will LINQ handle it well (ie, not puke)?
rlb.usa
I don't have any queries that complex, but I have built some that, through, chaining various components together end up being pretty complex. Depending on your query -- i.e., if you're building SQL to handle optional parts of the query, you may be able to simplify it by building the query up dynamically in LINQ. That is, you have some code in the app that builds up, say, a filter dynamically, adding only those components that are needed. The query turns out simpler, but you have the same power available to you -- part of it is just migrated to the app instead of the DB.
tvanfosson
A: 

if cursors are your big hang-up, you can loop without a cursor:

http://stackoverflow.com/questions/935336/sql-server-cursor-reference-syntax-etc/935367#935367

MySql has a WHILE loop:

http://dev.mysql.com/doc/refman/5.0/en/while-statement.html

just select the MIN(PK) and loop over the set SELECTing the MIN(PK)>currentPK that meets your WHERE clause.

KM