How to select from the output from a system stored procedure

  • I'm trying to select a column from the output from a system stored procedure, such as 'sp_lock' or 'sp_columns', similar to this:

    select objid from (exec sp_lock) where status = 'WAIT'

    Sorry for the newb question, don't even know what I'd put in Google to get an answer for this.

    TIA

    ----------------------------------------------------------------------------
    Sacramento SQL Server users group - http://sac.sqlpass.org
    Follow me on Twitter - @SQLDCH
    ----------------------------------------------------------------------------

    Yeah, well...The Dude abides.
  • 1- Create a temp table with columns matching the output of the desired storedproc.

    2- insert into #YourTempTable exec sp_YourStoredProc

    3- select from #YourTempTable as it fits you.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

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

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