Results 1 to 3 of 3

Thread: Problem in UDF

  1. #1
    Join Date
    Dec 2001
    Location
    India
    Posts
    25

    Unanswered: Problem in UDF

    Hi all,

    I created an UDF with a default Param
    For ex. getData(param1 integer, param2 varchar(10) = '')

    but while calling the udf, select getData(10), I am getting error.
    But the same is working with stored procedure.

    B. Selva Balaji.

  2. #2
    Join Date
    Jan 2002
    Posts
    12
    You have to reference the owner which in most cases is dbo.

    i.e. select dbo.getData(10), otherwise you'll get the error 'getData' is not a recognized function name.

  3. #3
    Join Date
    Dec 2001
    Location
    India
    Posts
    25
    Hi rlopez,

    I agree that I need to refer the UDF by dbo.

    But my question was about the default parameter in the UDF.

    Actually getData is having two parameters.
    The first parameter is must,
    and second will have a defult value.

    And the problem got solved by using the keyword 'default'
    select dbo.getData(10,default)
    -- '' will be considered as the value for second param
    select dbo.getData(10,'test')
    -- 'test' will be considered as the value for second param

    Regards,
    Selva Balaji B.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •