哪个查询显示SQL Server 2000中的特定数据库上的用户活动?我需要知道其中一个数据库中的所有用户都被挂起,还需要查看这些用户触发的查询
FUNCTION [dbo].[Show_my_process] (@SPID INT)
returns VARCHAR(8000)
AS
BEGIN
DECLARE @sql_handle BINARY(20),
@handle_found BIT
DECLARE @stmt_start INT,
@stmt_end INT
DECLARE @line NVARCHAR(4000),
@wait_str VARCHAR(8)
DECLARE @sql_process AS VARCHAR(8000)
SELECT @sql_handle = sql_handle,
@stmt_start = stmt_start / 2,
@stmt_end = CASE
WHEN stmt_end = -1 THEN -1
ELSE stmt_end / 2
END
FROM master.dbo.sysprocesses
WHERE spid = @spid
AND ecid = 0
SELECT @sql_process = Substring(text, COALESCE(NULLIF(@stmt_start, 0), 1),
CASE
@stmt_end
WHEN -1
THEN
Datalength(text)
ELSE (
@stmt_end - @stmt_start )
END)
FROM ::fn_get_sql(@sql_handle)
RETURN @sql_process
END
SELECT dbo.SHOW_MY_PROCESS(SPID)
FROM MASTER.DBO.SYSPROCESSES
WHERE SPID > 50
如果我运行此操作,我会收到查询,但问题是我看不到其他用户运行的查询