1. 看某个表被调用的关系:
sp_depends "{想查看的table or object}"
2. 这个可以帮做我们看目前哪些stored procedure在运行,或者挂起
SETTRANSACTIONISOLATIONLEVELREADUNCOMMITTED
-- What SQL Statements Are Currently Running?
SELECT [Spid] = session_Id
, ecid
, [Database] =DB_NAME(sp.dbid)
, [User] = nt_username
, [Status] = er.status
, [Wait] = wait_type
, [Individual Query] =SUBSTRING(qt.text,
er.statement_start_offset/2,
(CASEWHEN er.statement_end_offset=-1
THENLEN(CONVERT(NVARCHAR(MAX), qt.text))* 2
ELSE er.statement_end_offsetEND-
er.statement_start_offset)/2)
,[Parent Query] = qt.text
, Program =program_name
, Hostname
, nt_domain
, start_time
FROMsys.dm_exec_requests er
INNERJOINsys.sysprocesses sp ON er.session_id= sp.spid
CROSSAPPLYsys.dm_exec_sql_text(er.sql_handle)as qt
WHERE session_Id > 50 -- Ignore system spids.
AND session_Id NOTIN(@@SPID)-- Ignore this current statement.
ORDERBY 1, 2