Reputation: 6940
What is the difference between these two queries:
select hostname,* from sys.sysprocesses where spid = @@SPID;
select host_name()
Likely the second one, requires less permission to user executing query.
Upvotes: 0
Views: 529
Reputation: 8687
There is no difference from permissions point of view. Both queries can be executed having no permissions at all.
From sys.sysprocesses (Transact-SQL):
If a user has
VIEW SERVER STATE
permission on the server, the user will see all executing sessions in the instance of SQL Server; otherwise, the user will see only the current session.
In both cases the scope is current session only so there is no difference, and no permission is required.
Upvotes: 1