set nocount on
create table #sp_who (
spid smallint,
ecid smallint,
status nchar(30),
loginame nchar(128),
hostname nchar(128),
blk char(5),
dbname nchar(128),
cmd nchar(16),
requestid integer)
)
insert into #sp_who execute sp_who
select distinct loginame from #sp_who
drop table #sp_who
SQL Server
sql server