SQL: how to predicate over stored procedure's result sets?

前端 未结 3 1590
耶瑟儿~
耶瑟儿~ 2021-01-24 00:54

Simple question I couldn\'t figure out (not a SQL expert... sorry): I want to do a select on the result set of sp_who2. How can I?

for ex. select SPID from [result set f

3条回答
  •  长发绾君心
    2021-01-24 01:52

    You would have to insert the results into a table, a temporary table or a table variable.

    CREATE TABLE #sp_who2 (etc...)
    
    INSERT INTO #sp_who2 EXECUTE sp_who2
    
    SELECT * FROM #sp_who2 WHERE whatever...
    

    Another trick is using OPENROWSET

提交回复
热议问题