set variable to function result

  • How do you set a variable to the results of a function call passing one parameter ie

    declare @MyVariable varchar(50)

    set @MyVariable = MyFunction(@MyParameter)

  • you could try SELECT instead of SET, but I'm curious what error you are getting?

    CEWII

  • set @MyVariable = MyFunction(@MyParameter) and

    select @MyVariable = MyFunction(@MyParameter) gave the following error:

    'MyFunction' is not a recognized built-in function name.

  • L09041975 (1/27/2011)


    set @MyVariable = MyFunction(@MyParameter) and

    select @MyVariable = MyFunction(@MyParameter) gave the following error:

    'MyFunction' is not a recognized built-in function name.

    Did you try to call the function including the schema?

    E.g. select @MyVariable = dbo.MyFunction(@MyParameter)



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Thanks that works. 🙂

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

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