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. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 7 down vote accepted

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

share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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