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

    Question Unanswered: Is it possible to create a function from within a stored procedure?

    I would like to create an UDF from withing a stored procedure. Is it possible?

    Thanks a lot.

  2. #2
    Join Date
    Feb 2003
    Location
    Germany
    Posts
    53

    Re: Is it possible to create a function from within a stored procedure?

    Originally posted by EMoscosoCam
    I would like to create an UDF from withing a stored procedure. Is it possible?

    Thanks a lot.
    try something like this:

    declare @S varchar(1000)

    select @S='
    CREATE FUNCTION dbo.fn_test
    (
    @p1 int,
    @P2 int
    )
    RETURNS int
    AS
    BEGIN
    DECLARE @sum AS int
    SELECT @sum = @p1 + @P2
    RETURN @sum
    END'
    exec(@S)
    go
    select dbo.fn_test(5,2)

  3. #3
    Join Date
    Mar 2003
    Posts
    144

    Talking

    Thank you very much! it worked just fine.

Posting Permissions

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