Often I find myself wanting to filter or order the results returned by execing a stored procedure - for example to order the output of sp_who2 by login or CPU Time, or filter it by host name. What is the best way to achieve this?
Tell me more
×
Database Administrators Stack Exchange is a question and answer site for
database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
|
|
|||
|
|
|
One possible solution is to put the result set into a temp table and select from it. Here is an example for sp_who2: SQL Server: Filter output of sp_who2 |
|||
|
|
|
I love the SMSToolpack. its a free download and lets you sort the resulting grid of any sql query you run. On top of that, you can search the data just like searching for a text string in excel. it helps format you SQL text and makes it look pretty so you can be proud of your SQL code and much more... The best thing i think is it lets you color code windows to specific servers so its simple to know when you are running code on dev vs prod |
|||
|
|
