Functions quit working

  • Help, please.

    On an SQL Server 2000, we have created some user defined functions that have suddenly stopped working. They all quit working, but following is one example:

    SET QUOTED_IDENTIFIER OFF

    GO

    SET ANSI_NULLS OFF

    GO

    -- receive an number formatted as string

    -- and return a binary string equal

    CREATE       FUNCTION dbo.GetBinary3( @chardivisor char(10) = '' )

            RETURNS char(30)

    AS

    BEGIN

    declare @divisor as integer

    declare @remainder as integer

    declare @binary as char(35)

    set @divisor = cast(@chardivisor as int)

    set @remainder = 0

    set @binary = ''

     while @divisor > 0

       begin

          set @remainder = @divisor % 2

          set @divisor = @divisor / 2

          set @binary = cast(@remainder as char(1)) + @binary

       end

     --This is to make it 16 bit

     set @binary = Right('000000000000000' + rtrim(@binary),16)

    RETURN @binary

    END

    GO

    SET QUOTED_IDENTIFIER OFF

    GO

    SET ANSI_NULLS ON

    GO

    This function worked yesterday, now returns the following:

    Server: Msg 170, Level 15, State 1, Line 13

    Line 13: Incorrect syntax near 'FUNCTION'.

    Server: Msg 137, Level 15, State 1, Line 20

    Must declare the variable '@chardivisor'.

    Server: Msg 178, Level 15, State 1, Line 35

    A RETURN statement with a return value cannot be used in this context.

    We even get this message if we right click in QA and attempt to delete the function.

    Any ideas as to what is happening and how to resolve?

    Thanks for any ideas

    dsawford

  • Any changes in the servers?

    What about database compatibility level?

  • You solved the problem!  Somehow the compatibility level had been changed to 70.

    I don't know how it got changed, but thanks for you quick response.

    dsawford

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

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