Execute a Store Procedure in a select statment

  • Our ERP accept only sql statments for reporting.(I can write select ... but I can not  Write Exec Store_Procedure) .

    I Want to execute a Store Procedure in a select  statment.

     

  • No chance! That syntax is simply not supported.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • You cannot EXEC stored-procedures HOWEVER you can have user-defined functions in-line.  You may want to research UDFs and see if they can accomplush your desired results.



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • You have at least two options if you need to use the resultset from the stored procedure. 

    1) You can use the stored procedure to insert the results into a temporary table (e.g., INSERT tablename EXECUTE proc)

    2) OPENROWSET. 

    Randy
    Helpdesk: Perhaps Im not the only one that does not know what you are doing. 😉

  • However, if your login does not have execute permissions to a stored procedure, then syntax tricks will not help.  "Extra" access is not granted based on the T-SQL in the ad-hoc select.  This applies to udfs also. 

    Randy
    Helpdesk: Perhaps Im not the only one that does not know what you are doing. 😉

  • Thank You!!!! 

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

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