SQL Script to find the last executed commands on the SQl Server

Sometimes we needs to find out the last executed commands on the database server. 
Below is the SQL script share by one of my friend Ken Watson to find out the last executed queries.

SELECT usecounts, cacheobjtype, objtype, text 
FROM sys.dm_exec_cached_plans 
CROSS APPLY sys.dm_exec_sql_text(plan_handle) 
WHERE usecounts > 1 
ORDER BY usecounts DESC; 

About Ken
He is working as SQL DBA. 
Blog:-  interflextech.com/blog
Twitter:- @interflextech

About vivekjohari

Database Consultant with more than 11.5 years of experience in database designing & programming and DBA related activities.  Had good experience on different databases like SQL Server, MySQL & Oracle, Azure SQL &  Big Data.
This entry was posted in DBA, SQL Advanced, SQL Server and tagged . Bookmark the permalink.

30 Responses to SQL Script to find the last executed commands on the SQl Server

  1. Anvesh Patel says:

    Nice Article !

    Really this will help to people of SQL Server Community.
    I have also prepared small note on this, Script to find last executed query in SQL Server.

    http://www.dbrnd.com/2015/11/sql-server-script-to-find-the-last-executed-query-using-spid/

  2. Pingback: CD Printer in Lagos Nigeria

  3. Pingback: gazebo

  4. Pingback: Marketing Consultant

  5. Pingback: Dentist in Weslaco Texas 956-969-2960

  6. Pingback: polished concrete floor cost

  7. Pingback: Whatsapp Marketing Pro (Instant download link)

  8. Pingback: Istanaimpian2

  9. Pingback: Welding Equipment

  10. Pingback: New York Realtor

  11. Pingback: บาคาร่า

  12. Pingback: Sexual Function

  13. Pingback: Pflegematratze kaufen

  14. Pingback: https://www.wasseem.org/

  15. Pingback: Casa em Orlando

  16. Pingback: Online Casino

  17. Pingback: didi promotion code

  18. Pingback: Small business website designs and marketing

  19. Pingback: xembongda tructiep

  20. Pingback: decals for road cases

  21. Pingback: weight loss tracker

  22. Pingback: https://soundproofingcontractorsusa.info/usa/soundproofing/la

  23. Pingback: The Fylls (GoFundMe)

  24. Pingback: 바카라

  25. Pingback: Massage Danmark

  26. Pingback: social impact marketing

  27. Pingback: Dream Market

  28. Pingback: Tochka Market

  29. Pingback: mansion88

  30. Pingback: ebenin amini türkce dublaj izle

Leave a Reply