Question : sys.sysprocesses permissions

I have the view and the proc below -- my end-users, however, are unable to see the results.  what am I missing?

You can see the commented out section of the proc -- that was what I created originally, without the view, but realized I would have problems permissioning it to the varied end-users.  That's why I created the view.

Some users have SELECT on the view and EXEC on the proc, yet they still do not see the results.  Execution simply says 'completed successfully', nothing is returned.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
view:
CREATE VIEW [dbo].[vw_ActiveCxns] AS
SELECT db_name(dbid) as DatabaseName, hostname HostName, d.client_net_address IPaddress, loginame as LoginName, count(dbid) as NoOfConnections
FROM sys.sysprocesses s JOIN sys.dm_exec_connections d ON s.spid = d.session_id
WHERE dbid > 4
AND Loginame NOT IN (.............)
GROUP BY dbid, hostname,loginame,d.client_net_address

GO

proc:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROC [dbo].[usp_OpenCxns] (
 @login varchar(50)=NULL
)
AS
SET NOCOUNT ON;
/* Simply returns all active connections, per database.
EXEC dbo.usp_OpenCxns @login = 'xxxx' */
BEGIN TRAN
  BEGIN TRY
/*	SELECT db_name(dbid) as DatabaseName, hostname HostName, d.client_net_address IPaddress, loginame as LoginName, count(dbid) as NoOfConnections
	FROM sys.sysprocesses s JOIN sys.dm_exec_connections d ON s.spid = d.session_id
	WHERE dbid > 4
	AND (@login IS NULL OR s.loginame = @login)
	GROUP BY ROLLUP(dbid, hostname,loginame,d.client_net_address)
	ORDER BY DatabaseName,LoginName,d.client_net_address,NoOfConnections */
	SELECT DatabaseName,HostName,IPAddress,LoginName,NoOfConnections
	FROM dbo.vw_ActiveCxns
	WHERE (@login IS NULL OR LoginName = @login)
  END TRY
BEGIN CATCH
	ROLLBACK
END CATCH

IF @@TRANCOUNT >0
	COMMIT TRAN


SET NOCOUNT OFF;

GO

Answer : sys.sysprocesses permissions

Yes, your end-users need to have VIEW SERVER STATE privileges for them to get complete information from sys.sysprocesses view else they would be able to view only requests created from their login only.
Random Solutions  
 
programming4us programming4us