Friday, March 23, 2012

listing of sp_who

How can I get the listing of sp_who (or any other procedure)?Do you mean the definition of the procedure?
It depends on the version you are running. In the future, please always
provide version information.
You can use sp_helptext to get the definition of any procedure in the
current database, but in SQL 2005, the definitions of the system procedures
are in a database you can't get to (mssqlsystemresource). So you have to use
the new object_definition function.
SELECT object_definition(object_id('sp_who'))
--
HTH
Kalen Delaney, SQL Server MVP
http://sqlblog.com
"JayKon" <JayKon@.discussions.microsoft.com> wrote in message
news:428BABC3-2F06-42CA-AAB3-F7E16BA54196@.microsoft.com...
> How can I get the listing of sp_who (or any other procedure)?|||EXEC master..sp_helptext sp_who
"JayKon" <JayKon@.discussions.microsoft.com> wrote in message
news:428BABC3-2F06-42CA-AAB3-F7E16BA54196@.microsoft.com...
> How can I get the listing of sp_who (or any other procedure)?|||> You can use sp_helptext to get the definition of any procedure in the
> current database, but in SQL 2005, the definitions of the system
> procedures are in a database you can't get to (mssqlsystemresource).
This is not true for any of the sp_ procedures I've bothered to try,
including sp_who. The following works on 9.00.2047 and 9.00.3027:
EXEC master.sys.sp_helptext 'sp_help';
EXEC master.sys.sp_helptext 'sp_who';
EXEC master.sys.sp_helptext 'sp_who2';
EXEC master.sys.sp_helptext 'sp_helpdb';
EXEC master.sys.sp_helptext 'sp_configure';
EXEC master.sys.sp_helptext 'sp_spaceused';
EXEC master.sys.sp_helptext 'sp_helptext';
EXEC master.sys.sp_helptext 'sp_changedbowner';
EXEC master.sys.sp_helptext 'sp_columns_90_rowset';
EXEC master.sys.sp_helptext 'sp_addlogin';|||Thanks. After reading your other reply, I checked, and saw that this was
true. In an early beta of SQL2005 you couldn't use sp_helptext to get the
system procs; I've even got some old notes about that from one of the guys
on the dev team. So they changed this, probably after getting lots of
complaints!
--
HTH
Kalen Delaney, SQL Server MVP
http://sqlblog.com
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:%23llR$UpKHHA.3488@.TK2MSFTNGP02.phx.gbl...
>> You can use sp_helptext to get the definition of any procedure in the
>> current database, but in SQL 2005, the definitions of the system
>> procedures are in a database you can't get to (mssqlsystemresource).
> This is not true for any of the sp_ procedures I've bothered to try,
> including sp_who. The following works on 9.00.2047 and 9.00.3027:
>
> EXEC master.sys.sp_helptext 'sp_help';
> EXEC master.sys.sp_helptext 'sp_who';
> EXEC master.sys.sp_helptext 'sp_who2';
> EXEC master.sys.sp_helptext 'sp_helpdb';
> EXEC master.sys.sp_helptext 'sp_configure';
> EXEC master.sys.sp_helptext 'sp_spaceused';
> EXEC master.sys.sp_helptext 'sp_helptext';
> EXEC master.sys.sp_helptext 'sp_changedbowner';
> EXEC master.sys.sp_helptext 'sp_columns_90_rowset';
> EXEC master.sys.sp_helptext 'sp_addlogin';
>
>|||> Thanks. After reading your other reply, I checked, and saw that this was
> true. In an early beta of SQL2005 you couldn't use sp_helptext to get the
> system procs; I've even got some old notes about that from one of the guys
> on the dev team. So they changed this, probably after getting lots of
> complaints!
Yes, and I remember after they fixed that, complaining that you couldn't do:
EXEC sp_helptext 'sys.sp_who'
But you could do:
EXEC sp_helptext 'sp_who'
That has changed, because now you can do the former (and in the case of
dynamic management objects, you can't do the latter).
A

No comments:

Post a Comment