1 Version 4.0 -- 1/15/89 sp_helptext
______________________________________________________________________
NAME: sp_helptext
FUNCTION:
Prints the text of a stored procedure, trigger, view, default, or
rule.
SYNTAX:
sp_helptext objname
EXAMPLES:
1) sp_helptext ziprule
sp_helptext Version 4.0 -- 1/15/89 2
______________________________________________________________________
Displays the text of ziprule. Since this rule is in the pubs
database, this command must be issued from pubs.
------------
1
(1 row affected)
text
-------------------------------------------------
create rule ziprule
as @zip like "[0-9][0-9][0-9][0-9][0-9]"
(1 row affected)
2) sp_helptext sp_helptext
3 Version 4.0 -- 1/15/89 sp_helptext
______________________________________________________________________
Displays the text of sp_helptext. Since system procedures
are stored in master, this command must be executed from mas-
ter.
-----------
3
(1 row affected)
text
-------------------------------------------------------
/* helptext 1.5 5/4/87 */
create procedure sp_helptext
@objname varchar(92)
as
sp_helptext Version 4.0 -- 1/15/89 4
______________________________________________________________________
/*
** Make sure the @objname is local to the current database.
*/
if @objname like "%.%.%" and
substring(@objname, 1, charindex(".", @objname) - 1) != db_name()
begin
print
"Object must be in your current database."
return
end
/*
** Find out how many lines of text are coming back.
*/
select count(*)
5 Version 4.0 -- 1/15/89 sp_helptext
______________________________________________________________________
from syscomments
where id = object_id(@objname)
/*
** Now get the text.
*/
select text
from syscomments
where id
= object_id(@objname)
return
(3 rows affected)
PARAMETERS:
sp_helptext Version 4.0 -- 1/15/89 6
______________________________________________________________________
objname - is the name of the object for which you wish to see
the CREATE text. It must be in the current database.
COMMENTS:
o Executing sp_helptext prints out the number of rows in syscom-
ments (255 characters long each) that the object occupies, fol-
lowed by the CREATE text of the object.
o The procedure looks for the text in the syscomments table of
the current database only.
MESSAGES:
The objname parameter included a database name reference. The
objname must be in the current database.
PERMISSIONS:
Execute permission to public.
7 Version 4.0 -- 1/15/89 sp_helptext
______________________________________________________________________
TABLES USED:
syscomments
SEE ALSO:
sp_help, CREATE DEFAULT, CREATE PROCedure, CREATE RULE, CREATE
TRIGGER, CREATE VIEW