Good morning all,

I have never stored a function before, so I am not sure if I am doing something wrong or not.

I want a function to be able to extract the numerical values from a string. The string is usually "1111 aaaaaaaa" The numerical length can be 1-6 chars and the text is any length (it is a site code and then site name). The total field is Char(30).

I found a function Here
When I try to create this function using MySQL workbench it gives me the following error:

ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@strAlphaNumeric VARCHAR(256))

Could someone please tell me what I'm doing wrong?

Below is the Function taken from the link above.

CREATE FUNCTION dbo.udf_GetNumeric
(@strAlphaNumeric VARCHAR(256))
RETURNS VARCHAR(256)
AS
BEGIN
DECLARE @intAlpha INT
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric)
BEGIN
WHILE @intAlpha > 0
BEGIN
SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' )
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric )
END
END
RETURN ISNULL(@strAlphaNumeric,0)
END
GO