//查询系统语句堵塞
SELECT TOP 100 t.hostname,
t.loginame,
percent_complete,
[session_id] ,
der.[request_id] ,
[start_time] AS '开始时间' ,
der.[status] AS '状态' ,
[command] AS '命令' ,
dest.[text] AS 'sql语句' ,
DB_NAME([database_id]) AS '数据库名' ,
[blocking_session_id] AS '正在阻塞其他会话的会话ID' ,
[wait_type] AS '等待资源类型' ,
[wait_time] AS '等待时间' ,
[wait_resource] AS '等待的资源' ,
[reads] AS '物理读次数' ,
[writes] AS '写次数' ,
[logical_reads] AS '逻辑读次数' ,
[row_count] AS '返回结果行数',
t.hostname,
t.loginame
FROM sys.[dm_exec_requests] AS der
CROSS APPLY sys.[dm_exec_sql_text](der.[sql_handle]) AS dest
left JOIN sys.sysprocesses t ON t.spid=der.session_id
WHERE [session_id] > 1
-- AND DB_NAME(der.[database_id]) = 'gposdb'
ORDER BY [cpu_time] DESC
SELECT * FROM (SELECT t0.FDOCUMENTSTATUS fdocumentstatus, t0.FPRODUCTID fproductid_id, t0.FBOMID fbomid_id, t0.FSALEORDERNUMBER fsaleordernumber, t0.FBILLNO fbillno, t0.FBFLOWID fbflowid_id, t1.FSEQSRCENTRYID fseqsrcentryid, t2.FOPERNUMBER fopernumber, t2.FOPERQTY foperqty, t2_B.FQUALIFIEDQTY fqualifiedqty, t2_B.FUNQUALIFIEDQTY funqualifiedqty, t2.FPROCESSID fprocessid_id, t2.FOPERSTATUS foperstatus, t2_C.FACTIVITY1BASEQTY factivity1baseqty, t2_A.FISOUTSRC fisoutsrc, t2.FMULTIEMPNAME fmultiempname, t0.F_WJYU_KEHU f_wjyu_kehu_id, t2.F_WJYU_TEXT_FZ1 f_wjyu_text_fz1, t2.F_WJYU_TEXT_FZ2 f_wjyu_text_fz2, t2.F_WJYU_TEXT_FZ3 f_wjyu_text_fz3, t2.F_WJYU_TEXT_FZ4 f_wjyu_text_fz4, t2.F_WJYU_TEXT_FZ5 f_wjyu_text_fz5, t2.F_WJYU_TEXT_FZ6 f_wjyu_text_fz6, t2.FOPERUNITID foperunitid_id, t2_C.FACTIVITY1UNITID factivity1unitid_id, t0.F_WJYU_COMBO_JJZTDJT f_wjyu_combo_jjztdjt, t0.FBILLTYPE fbilltype, t0.FPROORGID fproorgid, t0.FPROORGID fproorgid_id, t0.FMOENTRYID fmoentryid, t2.FWORKCENTERID fworkcenterid, t2.FDEPARTMENTID fdepartmentid, t2.FPROCESSORGID fprocessorgid, t2.FBARCODE fbarcode, t0.FFORMID fformid, t0.FID fid, t1.FENTRYID t1_fentryid, t2.FDETAILID t2_fdetailid, t1.FSeq t1_fseq, t2.FSeq t2_fseq, ROW_NUMBER() OVER( ORDER BY t0.FCREATEDATE DESC, t0.FBILLNO DESC, t1.FSeq ASC, t2.FSeq ASC) fidentityid FROM T_SFC_OPERPLANNING t0 LEFT OUTER JOIN T_SFC_OPERPLANNINGSEQ t1 ON t0.FID = t1.FID LEFT OUTER JOIN T_SFC_OPERPLANNINGDETAIL t2 ON t1.FENTRYID = t2.FENTRYID LEFT OUTER JOIN T_SFC_OPERPLANNINGDETAIL_A t2_A ON t2.FDETAILID = t2_A.FDETAILID LEFT OUTER JOIN T_SFC_OPERPLANNINGDETAIL_B t2_B ON t2.FDETAILID = t2_B.FDETAILID LEFT OUTER JOIN T_SFC_OPERPLANNINGDETAIL_C t2_C ON t2.FDETAILID = t2_C.FDETAILID WHERE (((t0.FPROORGID = 1 OR EXISTS (SELECT IUT.FID FROM T_SFC_OPERPLANNING_ISSUE IUT WHERE (IUT.FID = t0.FID AND IUT.FISSUEORGID = 1))) AND (t0.FPROORGID IN (1, 0) OR EXISTS (SELECT IUT.FID FROM T_SFC_OPERPLANNING_ISSUE IUT WHERE (IUT.FID = t0.FID AND IUT.FISSUEORGID IN (1, 0))))) AND t0.FFORMID = 'SFC_OperationPlanning')) tlist WHERE ((fidentityid >= 1) AND (fidentityid <= 10000))