Syntax error(156) in UDF

  • Hey folks,

    I'm receiving the following error message when I check the syntax of my UDF:

    Error 156: Incorrect syntax near the keyword 'SET'.

     

    Here is the UDF which is producing the error:

    CREATE FUNCTION dbo.FnIsStandard (@Fname as VarChar(50)) 

    RETURNS Char(2) AS 

    BEGIN

     Declare @res Char(2)

     IF IsNumeric(SubString(@Fname, 1, 2))

      SET @res=SubString(@Fname, 1, 2)

     Return @res

    END

    I've looked through the BOL and checked articles like this and I can't see where I've got the syntax wrong.  Can anyone help me out or point me in the right direction?

     

  • IF IsNumeric(SubString(@Fname, 1, 2)) = 1

    _____________
    Code for TallyGenerator

  • Brilliant Sergiy, that fixed it.  Thanks very much

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply