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?

2 Answers 2


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.