In recent SQL Training I was asked, how can one figure out what was the last SQL Statement executed in sessions. The query for this is very simple. It uses two DMVs and created following quick script for the same. SELECT session_id, TEXT FROM sys.dm_exec_connections CROSS APPLY sys.dm_exec_sql_text(most_recent_sql_handle) AS ST While…Read More
During several recent training courses, I found it very interesting that Worker Thread is not quite known to everyone despite the fact that it is a very important feature. At some point in the discussion, one of the attendees mentioned that we can double the Worker Thread if we double…Read More
SQL SERVER – DMV Error: FIX: Error: Msg 297, Level 16 The user does not have permission to perform this action
I just received an email from one of the readers asking for help with error he encountered while attempting to run DMV. Msg 297, Level 16, State 1, Line 1 The user does not have permission to perform this action. Fix/Solution/Workaround: The above error is usually generated when the user…Read More
About a year ago, I wrote blog post about SQL SERVER – 2005 – Last Ran Query – Recently Ran Query. Since, then I have received many question regarding how this is better than fn_get_sql() or DBCC INPUTBUFFER. The Short Answer in is both of them will be deprecated. Please…Read More
The CPU is responsible for not only SQL Server operations but also all the OS tasks related to the CPU. Let us learn about measuring CPU Pressure.
This post is about a riveting observation I made a few days back. While playing with transactions I came across two DMVs that are associated with Transactions. 1) sys.dm_tran_active_transactions – Returns information about transactions for the instance of SQL Server. 2) sys.dm_tran_current_transaction – Returns a single row that displays the…Read More
It is very often I get query that how to find if any index is being used in database or not. If any database has many indexes and not all indexes are used it can adversely affect performance. If number of index is higher it reduces the INSERT / UPDATE…Read More