My favorite query

Are queries like children? Sure, you spend valuable time raising/developing them hoping for the best. They give you trouble at times and can be very rewarding at others. Do they require long term care? Yes. Do you assure them and all others that you love them equally? No. I see similarites between queries and children, especially when talking about the rewards and troubles. Among the many differences is the equality part. I do not love all my queries equally. I have no shame in picking favorites or speaking dismissively of others. Here is my favorite (at least for now) query.

SELECT status, command, percent_complete, wait_type
FROM sys.dm_exec_requests
WHERE session_id = 54

The session_id bit comes and goes, but sys.dm_exec_requests is a wonderful DMV that I go to time and time again. It’s up in a SSMS window on my other monitor right now as a backup restores. It is so much more satisfying to see the percent_complete column increment up with an end in sight than it is to watch the seconds tick by in to minutes at the bottom of a long running restore.

I’m not getting results any more from my favorite query, time to go.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s