Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7057383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:58:46+00:00 2026-05-28T03:58:46+00:00

We have this recurring situation where several times a week our application stops responding.

  • 0

We have this recurring situation where several times a week our application stops responding. What I would like to do is be able to view the text of the query running on SQL Server.

I can use sp_who to see the open connections, but, it does not display the actual query text.

If I can see the query that is freezing my database I can have a starting point for optimization.

This happened a few minutes ago and our sys admin had to reboot the box. This rebooting is not sustainable.

What steps should I take?

I would like to see the actual text of the queries that are running on my server.

SQL Server 2000

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:58:46+00:00Added an answer on May 28, 2026 at 3:58 am

    use this while the block is happening:

    SELECT
        r.session_id AS spid
            ,r.cpu_time,r.reads,r.writes,r.logical_reads 
            ,r.blocking_session_id AS BlockingSPID
            ,LEFT(OBJECT_NAME(st.objectid, st.dbid),50) AS ShortObjectName
            ,LEFT(DB_NAME(r.database_id),50) AS DatabaseName
            ,s.program_name
            ,s.login_name
            ,OBJECT_NAME(st.objectid, st.dbid) AS ObjectName
            ,SUBSTRING(st.text, (r.statement_start_offset/2)+1,( (CASE r.statement_end_offset
                                                                      WHEN -1 THEN DATALENGTH(st.text)
                                                                      ELSE r.statement_end_offset
                                                                  END - r.statement_start_offset
                                                                 )/2
                                                               ) + 1
                      ) AS SQLText
        FROM sys.dm_exec_requests                          r
            JOIN sys.dm_exec_sessions                      s ON r.session_id = s.session_id
            CROSS APPLY sys.dm_exec_sql_text (sql_handle) st
        WHERE r.session_id!=@@SPID
    

    this will list all active SPIDs, who is blocking them and the SQL of each SPID

    EDIT
    this query is for SQL Server 2005+, initial question did not state SQL Server 2000

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I enjoy developing algorithms using the STL, however, I have this recurring problem where
I have this idea for a free backup application. The largest problem I need
Here's the situation... Site 1) ASP.NET MVC application for customers to login, view and
I have a situation where I'd like to do something like... (define (def a
This is a recurring question for me, but I'd like to reiterate. Quickly explain
We have scalar functions in our database for returning things like number of tasks
In this situation, I have created a zip file containing search result files, and
This is the situation: I have two tables where the one references the other
I have a situation which involves several threads simultaneously populating a database with data
Here's my situation: I have two pages. I use this line of code to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.