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 8119181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:43:46+00:00 2026-06-06T04:43:46+00:00

I require is to have a single stored procedure which can execute and show

  • 0

I require is to have a single stored procedure which can execute
and show

“all SQL for the current connection which has previously run” and “not currently running”.

I have searched a lot about this and I am not able to find the answer. Please help me on this.

  • 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-06-06T04:43:48+00:00Added an answer on June 6, 2026 at 4:43 am

    It is better to use the Profiler for this task.

    But if you want a query in SQL Server 2005+ you can use system views sys.dm_exec_query_stats, which returns aggregate performance statistics for cached query plans but only for the cashed plans, and sys.dm_exec_sql_text. Unfortunately they don’t have information about session ID so you can get only cashed queries of a server instance.

    set transaction isolation level read uncommitted
    select top 1000
        creation_time,
        last_execution_time,
        case 
            when sql_handle IS NULL then ' '
            else(substring(st.text,(qs.statement_start_offset+2)/2,(
                case
                    when qs.statement_end_offset =-1 then len(convert(nvarchar(MAX),st.text))*2      
                    else qs.statement_end_offset    
                end - qs.statement_start_offset)/2  ))
        end as query_text,
        db_name(st.dbid)as db_name,
        object_schema_name(st.objectid, st.dbid)+'.'+object_name(st.objectid, st.dbid) as object_name
    FROM sys.dm_exec_query_stats  qs
         cross apply sys.dm_exec_sql_text(sql_handle) st
    ORDER BY db_name, object_name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a single procedure that has two insert statements in it for two
I have the following 3 rails classes, which are all stored in one table,
i have many textboxes on a form and all textboxes require to have a
I have an application running in IIS which connects to a SQL Server 2008
I have a big stored procedure that I run. At the end its supposed
I have a trip that has many residencies. I need a single query that
I have a single PHP file that i require in many different php files.
I have just found a script we are using which has a sub that
I have tree structures that are stored in a DB table. The table can
In my live site I have php include() and require() that have full path

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.