Query the statements being executed by SQLServer

Source: Internet
Author: User
No SELECT [Spid] session_Id, ecid, [Database] DB_NAME (sp. dbid), [User] nt_username, [Status] er. STATUS, [Wait] wait_type, [IndividualQuery] SUBSTRING (qt. TEXT, er. statement_start_offset2, (CASEWHENer. s

No SELECT [Spid] = session_Id, ecid, [Database] = DB_NAME (sp. dbid), [User] = nt_username, [Status] = er. STATUS, [Wait] = wait_type, [Inpidual Query] = SUBSTRING (qt. TEXT, er. statement_start_offset/2, (case when er. s

Query the statements being executed by SQL Server
<无>
SELECT [Spid] = session_Id,ecid,[Database] = DB_NAME(sp.dbid),[User] = nt_username,[Status] = er.STATUS,[Wait] = wait_type,[Inpidual Query] = SUBSTRING(qt.TEXT, er.statement_start_offset / 2, (CASE WHEN er.statement_end_offset = - 1THEN LEN(CONVERT(NVARCHAR(MAX), qt.TEXT)) * 2ELSE er.statement_end_offsetEND - er.statement_start_offset) / 2),[Parent Query] = qt.TEXT,Program = program_name,Hostname,nt_domain,start_timeFROM sys.dm_exec_requests erINNER JOIN sys.sysprocesses sp ON er.session_id = sp.spidCROSS APPLY sys.dm_exec_sql_text(er.sql_handle) AS qtWHERE session_Id > 50 /* Ignore system spids.*/AND session_Id NOT IN (@@SPID)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.