How can I exec stored procedure inside a function?

  • I have a stored procedure that accepts 6 parameters and returns a table.  How can I execute this stored procedure inside a function?

    Thank you

  • Per Books Online:

    "The types of statements that are valid in a function include:

    • DECLARE statements can be used to define data variables and cursors that are local to the function.
    • Assignments of values to objects local to the function, such as using SET to assign values to scalar and table local variables.
    • Cursor operations that reference local cursors that are declared, opened, closed, and deallocated in the function. FETCH statements that return data to the client are not allowed. Only FETCH statements that assign values to local variables using the INTO clause are allowed.
    • Control-of-flow statements.
    • SELECT statements containing select lists with expressions that assign values to variables that are local to the function.
    • UPDATE, INSERT, and DELETE statements modifying table variables that are local to the function.
    • EXECUTE statements calling an extended stored procedure. "

    It would appear that you can't run a user stored procedure within a function.

    Matt

Viewing 2 posts - 1 through 1 (of 1 total)

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