如何将我的存储过程从MS-SQL转换为MySQL? [英] How do I Convert my Store procedure from MS-SQL to MySQL ?

查看:67
本文介绍了如何将我的存储过程从MS-SQL转换为MySQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 MS-SQL 中有这个存储过程:



I have this Store Procedure in MS-SQL:

USE [LoginDB]
GO
/****** Object:  StoredProcedure [dbo].[Validate_User]    Script Date: 08/24/2014 15:29:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER  PROCEDURE [dbo].[Validate_User]
	@Username NVARCHAR(20),
	@Password NVARCHAR(20)
AS
BEGIN
	SET NOCOUNT ON;
	DECLARE @UserId INT, @LastLoginDate DATETIME
	
	SELECT @UserId = UserId, @LastLoginDate = LastLoginDate 
	FROM Users WHERE Username = @Username AND [Password] = @Password
	
	IF @UserId IS NOT NULL
	BEGIN
		IF NOT EXISTS(SELECT UserId FROM UserActivation WHERE UserId = @UserId)
		BEGIN
			UPDATE Users
			SET LastLoginDate =  GETDATE()
			WHERE UserId = @UserId
			SELECT @UserId [UserId] -- User Valid
		END
		ELSE
		BEGIN
			SELECT -2 -- User not activated.
		END
	END
	ELSE
	BEGIN
		SELECT -1 -- User invalid.
	END
END





-------------------

我应该如何在 MySQL 中编写这个存储过程?



-------------------
How should i write this store procedure in MySQL ?

推荐答案

http://www.thegeekstuff.com/2014/03/mssql-to-mysql-stored-procedure/ [ ^ ]


嘿,试试这个

将MS-SQL Server存储过程转换为MySQL查询

^]



http://stackoverflow.com/questions/203 29643 / convert-ms-sql-server-stored-procedure-to-mysql-query



:):)
Hey, try this
Convert MS-SQL Server stored procedure to MySQL Query
^]

http://stackoverflow.com/questions/20329643/convert-ms-sql-server-stored-procedure-to-mysql-query

:) :)


没有这方面的工具,所以你必须手动进行转换。

这是一个非常简单的转换,但通常我会先记录SP的功能。记录您的程序有助于理解。



然后查看MySQL站点并阅读文档了解它们的存储过程。

DDL语法类似,SQL语法是相同。



第19章存储的程序和视图 [ ^ ]



13.1.12创建过程和创建函数语法 [ ^ ]



MySQL存储过程 [ ^ ]
There are no tools for this, so you have to do the conversion manually.
This is a pretty straight forward conversion, but normally I would start with documenting the functionality of the SP. It is good for the understanding to have your procedures documented.

Then check out the MySQL site and read the documentation for their stored procedures.
The DDL syntax is similar and the SQL syntax is the same.

Chapter 19 Stored Programs and Views[^]

13.1.12 CREATE PROCEDURE and CREATE FUNCTION Syntax[^]

MySQL Stored Procedure[^]


这篇关于如何将我的存储过程从MS-SQL转换为MySQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆