Question

I find this function

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

and I want to use it, but i got an error like

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)) RETURNS VARCHAR(256) AS BEGIN DECLARE @intAlp' at line 2

my version of phpmyadmin is 4.0.10

No correct solution

OTHER TIPS

You're returning a boolean with this line you defined RETURN ISNULL(@strAlphaNumeric,0). You must return a VARCHAR instead if this is really what you are trying to implement. Try changing your RETURNS VARCHAR(256) with RETURNS TINYINT(1) and see if this will work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top