Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003
    Posts
    144

    Question Unanswered: How can I retrieve a function return value from an executed string?

    Hello!

    Suppose that I have the name of an UDF (@Function) which returns an scalar value and accepts just one parameter. How can I execute and assign the return value to a variable?

    I tried the following, but it did not work:

    declare @Receptor as sql_variant

    set @Receptor=execute('select ' + @Function + '(10)')

    Thanks a lot in advance.

  2. #2
    Join Date
    Feb 2003
    Location
    Montreal, Canada
    Posts
    117

    Re: How can I retrieve a function return value from an executed string?

    The function is not completely qualified (DB name, owner)
    Try:

    declare @Receptor as sql_variant
    set @Receptor = database_name.dbo.Function(@in_param_value)

    A user defined function can be used like any other pre-defined function

    Originally posted by EMoscosoCam
    Hello!

    Suppose that I have the name of an UDF (@Function) which returns an scalar value and accepts just one parameter. How can I execute and assign the return value to a variable?

    I tried the following, but it did not work:

    declare @Receptor as sql_variant

    set @Receptor=execute('select ' + @Function + '(10)')

    Thanks a lot in advance.
    Steve

Posting Permissions

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