Error message for function did not not a recognized

  • SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_NULLS ON

    GO

    create FUNCTION dbo.combine_cptcode

      (@pid As char(8))

    RETURNS varchar(1000)

    AS

    BEGIN

      DECLARE @cptcode  AS varchar(1000)

      SET @cptcode  = ''

      SELECT @cptcode =   case  @cptcode  when '' then BILLINGHC

    else  @cptcode + BILLINGHC   END from CPTCodeop  where atientID=@pid">PatientID=@pid order by BILLINGHC 

        

     

      RETURN @cptcode

     

    END

    GO

    SET QUOTED_IDENTIFIER OFF

    GO

    SET ANSI_NULLS ON

    GO

     

    I created the above function. I can see that and ALTER that. but

    it gave me error while I run this query.

    select PatientID, combine_cptcode(PatientID) from   CPTCodeop

    Server: Msg 195, Level 15, State 10, Line 1

    'combine_cptcode' is not a recognized function name.

    Do not know why

    I created my function according to

    http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

     

    Thx.

  • INSTEAD of

    select PatientID, combine_cptcode(PatientID) from   CPTCodeop

    PUT

    select PatientID, dbo.combine_cptcode(PatientID) from   CPTCodeop

     

    NOTE the dbo.

  • Thx. it has results , but the results are not my expected. but the BILLINGHC is not append . I looked at my function is nothing different from the example.

     

    SET QUOTED_IDENTIFIER OFF

    GO

    SET ANSI_NULLS ON

    GO

    ALTER   FUNCTION dbo.combine_cptcode

      (@pid As char(8))

    RETURNS varchar(1000)

    AS

    BEGIN

      DECLARE @cptcode  AS varchar(1000)

      SET @cptcode  = ''

      SELECT @cptcode =   case  @cptcode  when '' then BILLINGHC

                        else

                        @cptcode + ','+ BILLINGHC  

                           END

             from CPTCodeop  where <A href="mailtoatientID=@pid">PatientID=@pid order by BILLINGHC

        

    RETURN @cptcode

    end

     

    GO

    SET QUOTED_IDENTIFIER OFF

    GO

    SET ANSI_NULLS ON

    GO

     

    select distinct PatientID, dbo.combine_cptcode(PatientID) from   CPTCodeop group  by PatientID

  • It looks like all that this will ever return is BILLINGHC, it will never get to the else statment.

     

    Please give me an example of what the data is and what the results should be, then I should be able to tell you what is wrong.

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

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