SQL Server 到 MySQL - 但如何使用存储过程呢?
我的任务是将 SQL Server 数据库转换为 MySQL 5.* 数据库。 我觉得自己已经充分了解了数据类型之间的转换。
然而,我读到 MySQL 使用 ANSI,而不是 T-SQL,并且不支持游标。 我的问题是,我应该如何处理我的所有 SQL Server 函数和存储过程(其中一些使用游标)?
我想“以正确的方式进行操作” ”。
我是否将它们全部移动到像 SqlCommand cmd = new SqlCommand("SELECT * FROM ...", con"); 这样的代码,我是否将它们移动到 MySQL 的 procedure-things,我应该尝试 jQuery,或 LINQ,或...?
前端仍将使用 ASP.NET,但我们有可能将其重写/移动到 PHP。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不认为 jQuery 会有帮助,但如果您转向 LINQ,您可能可以完全不用 SPROCS。自从我开始使用 LINQ 作为我的(轻量级)ORM 以来,我很少使用 SPOC。
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.
如果游标是您的大难题,您可以在没有游标的情况下循环:
SQL Server 游标参考(语法等)
MySql 有一个 WHILE 循环:
http://dev.mysql.com/doc/refman/5.0/en/while-statement.html
只需选择 MIN(PK) 并循环遍历集合 SELECTing MIN(PK) >满足 WHERE 子句的 currentPK。
if cursors are your big hang-up, you can loop without a cursor:
SQL Server Cursor Reference (Syntax, etc)
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.