2011-12-02 50 views

回答

0

你可以用SQL Server Profiler中做到這一點

http://i.stack.imgur.com/p7Asn.png

enter image description here 也試試這個:

SELECT sqltext.TEXT, 
req.session_id, 
req.status, 
req.command, 
req.cpu_time, 
req.total_elapsed_time 
FROM sys.dm_exec_requests req 
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext 
+0

是的,但是有可能在SP或觸發器中跟蹤它嗎? –

2

您可以從sysprocesses中你認爲合適的添加等欄目,你需要首先創建ProcessLog表。

CREATE TRIGGER [dbo].[LogDelete] ON [dbo].[SampleTable] AFTER DELETE AS 
BEGIN 
    SET NOCOUNT ON; 

    INSERT INTO dbo.ProcessLog 
    SELECT 
      program_name 
     , net_address 
     , hostname 
    FROM 
     sys.sysprocesses 
    WHERE 
     spid = @@SPID 
END 
相關問題