存储过程MSSQL到MYSQL

时间:2014-02-01 05:30:31

标签: mysql sql procedure

我需要将这个存储过程mssql转换为mysql,有人请帮助我

1)

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[sp_IS]
as
insert into request (dateIS) values (GETDATE())

2)

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[sp_RN]
as
select COUNT(id) "quantity" from notify

谢谢!

2 个答案:

答案 0 :(得分:0)

看看这个

CREATE

[DEFINER = { user | CURRENT_USER }]

PROCEDURE sp_name ([proc_parameter[,...]])

[characteristic ...] routine_body

CREATE

[DEFINER = { user | CURRENT_USER }]

FUNCTION sp_name ([func_parameter[,...]])

RETURNS type

[characteristic ...] routine_body

 proc_parameter:

[ IN | OUT | INOUT ] param_name type

 func_parameter:

param_name type

 type:

Any valid MySQL data type

characteristic:

 COMMENT 'string'

 | LANGUAGE SQL

 | [NOT] DETERMINISTIC

 | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }

 | SQL SECURITY { DEFINER | INVOKER }

 routine_body:

Valid SQL routine statement

答案 1 :(得分:0)

修改存储过程

MySQL提供了一个ALTER PROCEDURE语句来修改例程,但只允许更改某些特性。如果需要更改主体或参数,则必须删除并重新创建该过程。

DROP PROCEDURE IF EXISTS sp_IS;
delimiter //
create PROCEDURE sp_IS 
    BEGIN
      insert into request (dateIS) values (GETDATE())
    END
delimiter;

DROP PROCEDURE IF EXISTS sp_RN;
    delimiter //
    create PROCEDURE sp_RN 
        BEGIN
          select COUNT(id) AS quantity from notify
        END
delimiter;