如何将mssql函数转换为mysql?

时间:2018-02-26 07:08:31

标签: mysql sql-server user-defined-functions

我有MSSQLserver DB我将迁移到MYSQL。我已经转换了几乎所有stored procedures,但我无法convert mssql user defined function转换为mysql function

MSSQL功能:

create Function [dbo].[CsvSplit] ( @Array varchar(max),@separator varchar(5)) 
returns @IntTable table 
    (RValue nvarchar(400))
AS
begin

--  declare @separator char(1)
--  set @separator = ','

    declare @separator_position int 
    declare @array_value varchar(1000) 

    set @array = @array + @separator

    while patindex('%'+@separator+'%' , @array) <> 0 
    begin

      select @separator_position =  patindex('%'+@separator+'%' , @array)
      select @array_value = left(@array, @separator_position - 1)
    if len(@array_value)>0 
        Insert @IntTable
        Values (@array_value )

      select @array = stuff(@array, 1, @separator_position, '')
    end

    return
end

用法:

SELECT TOP 1 lower(RValue) FROM CsvSplit('s,d,b',',')

任何人都可以帮我将同样的函数转换为mysql吗?

0 个答案:

没有答案