Blog Layout

SQL KILLBILL What Is Running SnapShot ?

E.DIN Editor • May 14, 2020
KUNG FU SQL - SNAPSHOT OF SITUATION ON ANY SQL SERVER

--kill 111
              SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
              SELECT
                       @@servername as 'SrvrName'
                     ,GETDATE() as 'SnapShotTime'
                     ,StartTime          = er.start_time
                     ,SPID                = er.session_id
                     ,BlkBy              = er.blocking_session_id     
                      ,ElapsedMS          = er.total_elapsed_time
                     ,CPU                = er.cpu_time
                     ,IOReads            = er.logical_reads + er.reads
                     ,IOWrites           = er.writes    
                      ,Executions         = ec.execution_count 
                      ,CommandType        = er.command        
                      ,ObjectName         = OBJECT_SCHEMA_NAME(qt.objectid,qt.dbid) + '.' + OBJECT_NAME(qt.objectid, qt.dbid) 
                      ,SQLStatement       =
                           SUBSTRING
                           (
                                  qt.text,
                                  er.statement_start_offset/2,
                                  (CASE WHEN er.statement_end_offset = -1
                                         THEN LEN(CONVERT(nvarchar(MAX), qt.text)) * 2
                                         ELSE er.statement_end_offset
                                         END - er.statement_start_offset)/2
                           )       
                      ,STATUS             = ses.STATUS
                     ,[Login]            = ses.login_name
                     ,Host               = ses.host_name
                     ,DBName             = DB_Name(er.database_id)
                     ,LastWaitType       = er.last_wait_type
                     ,Protocol           = con.net_transport
                     ,transaction_isolation =
                           CASE ses.transaction_isolation_level
                                  WHEN 0 THEN 'Unspecified'
                                  WHEN 1 THEN 'Read Uncommitted'
                                  WHEN 2 THEN 'Read Committed'
                                  WHEN 3 THEN 'Repeatable'
                                  WHEN 4 THEN 'Serializable'
                                  WHEN 5 THEN 'Snapshot'
                           END
                     ,ConnectionWrites   = con.num_writes
                     ,ConnectionReads    = con.num_reads
                     ,ClientAddress      = con.client_net_address
                     ,Authentication     = con.auth_scheme
                     ,QueryPlan          = CONVERT(nvarchar(MAX),qp.query_plan)
                     ,PlanHandle         = er.plan_handle
              --INTO myDatabase.dbo.dmv_reqs_20200514
              FROM sys.dm_exec_requests er
              LEFT JOIN sys.dm_exec_sessions ses
              ON ses.session_id = er.session_id
              LEFT JOIN sys.dm_exec_connections con
              ON con.session_id = ses.session_id
              CROSS APPLY sys.dm_exec_sql_text(er.sql_handle) AS qt
              OUTER APPLY
              (
                     SELECT execution_count = MAX(cp.usecounts)
                     FROM sys.dm_exec_cached_plans cp
                     WHERE cp.plan_handle = er.plan_handle
              ) ec
              CROSS APPLY sys.dm_exec_query_plan(plan_handle) qp
              WHERE er.session_id <> @@SPID
              ORDER BY
                     er.blocking_session_id DESC,
                     er.logical_reads + er.reads DESC,
                     er.session_id OPTION (RECOMPILE);
GO
By E.DIN Editor 17 Nov, 2021
Title: Base64 Encoding With Simple Salt (and decoding)
By E.DIN Editor 17 Nov, 2021
XPCMD_SHELL Move & Load Data from Directory
By E.DIN Editor 17 Nov, 2021
By E.DIN Editor 17 Nov, 2021
By E.DIN Editor 01 Oct, 2020
 ***** My Valid Data Monitor **** XML OUT *** HTML EMAIL DELIVERY  *****IF OBJECT_ID('tempdb..#tCustomerID') IS NOT NULL DROP TABLE #tCustomerID    select distinct         mm.CustomerID  Into #tCustomerID    from myDatabase..myTable (nolock) mm     left join myDatabase.dbo.myOtherTable (nolock) mo  on mm.refID = mo.id     left join myDatabase.dbo.myOtherTableDetail (nolock) mod  on mo.id = mod.myOtherTableid         and mm.SearchValue = mod.SearchValue     where mm.refID is not null     and mm.quantity is not null      and mod.SearchValue is nullIF Exists (Select 1 From #tCustomerID)BEGIN DECLARE @xml NVARCHAR(MAX)DECLARE @body NVARCHAR(MAX)SET @xml = CAST(( SELECT [CustomerID] AS 'td' FROM #tCustomerID ORDER BY CustomerID FOR XML PATH('tr'), ELEMENTS ) AS NVARCHAR(MAX))SET @body ='

My Valid Data Monitor

'    SET @body = @body + @xml +'
CustomerID
'--SELECT @body  exec msdb.dbo.sp_send_dbmail  @profile_name  = 'dbmailProfile' ,@recipients    = 'usergroup@mydomain.com' ,@subject       = 'My Valid Data Monitor' ,@body          = @body ,@body_format   = 'HTML'END
By websitebuilder 20 Sep, 2020
The new season is a great reason to make and keep resolutions. Whether it’s eating right or cleaning out the garage, here are some tips for making and keeping resolutions.
By websitebuilder 20 Sep, 2020
There are so many good reasons to communicate with site visitors. Tell them about sales and new products or update them with tips and information.
By websitebuilder 20 Sep, 2020
Write about something you know. If you don’t know much about a specific topic that will interest your readers, invite an expert to write about it.
By tekp 15 Jul, 2020
Turn Up! Not every microphone has the same base volume for transmitting your voice through your computer to whoever or whatever is on the other end of the exchange. Some microphones have a higher volume as compared to others, and some microphones have a volume that is so low that the person on the other […] The post How to Turn Up Mic Volume in Windows 10 – Appuals.com appeared first on TekPreacher.
By E.DIN Editor 09 Jun, 2020
'+@UNCPathAndLogTable+'
More Posts
Share by: