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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| 1> sp_helptext sp_who
2> go
# Lines of Text
---------------
7
(1 row affected)
text
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */
/* 4.8 1.1 06/14/90 sproc/src/serveroption */
/*
** Messages for "sp_who" 17nnn
**
** 17231, "No login with the specified name exists."
*/
create procedure sp_who @loginame varchar(255) = NULL as
decla
re @low int
declare @high int
declare @spidlow int
declare @spidhigh int
declare @len1 int, @len2 int, @len3 int
if @@trancount = 0
begin
set chained off
end
set transaction isolation level 1
select @low = @@minsuid, @high = @@maxsuid,
@spidl
ow = @@minspid, @spidhigh = @@maxspid
if @loginame is not NULL
begin
select @low = suser_id(@loginame), @high = suser_id(@loginame)
if @low is NULL
begin
if @loginame like "[0-9]%"
begin
select @spidlow = convert(int, @loginame),
@spidh
igh = convert(int, @loginame),
@low = @@minsuid, @high = @@maxsuid
end
else
begin
/*
** 17231, "No login with the specified name exists."
*/
raiserror 17231
return (1)
end
end
end
begin
select fid,spid,status,login
ame=suser_name(suid),
origname=isnull(suser_name(origsuid), suser_name(suid)), hostname,
blk_spid=blocked, dbname=db_name(dbid), tempdbname=db_name(tempdb_id(spid)),
cmd, block_xloid
into #who1result
from master..sysprocesses
where suid >=
@low and suid <= @high
and spid >= @spidlow and spid <= @spidhigh
exec sp_autoformat @fulltabname = #who1result,
@selectlist = "fid, spid, status, loginame, origname, hostname, blk_spid, dbname, tempdbname, cmd, block_xloid",
@orderby = "order by fid, spid, dbname"
drop table #who1result
end
return (0)
(7 rows affected)
(return status = 0) |
Partager