dump tran sybsystemprocs with truncate_only
go

use sybsystemprocs
go

if exists (select * from sysobjects where name = "sp_helpcode" and type = 'P')
   drop proc sp_helpcode
go

create procedure sp_helpcode @objname varchar(92)
as

--*********************************************************************
--* Stored procedure  sp_helpcode  for Sybase or Microsoft SQL Server 
--* Author:       Andrew Zanevsky, AZ Databases, Inc.
--* Date:         March 16, 1995
--* Description:  Works similar to standard system stored procedure
--*               sp_helptext. Correclty handles cases when a substring 
--*               begins in one row of syscomments table and continues 
--*               in the next (no split lines!).
--*               Uses print command (not select) to generate the result
--*               for technical reasons.
--* Parameters: - @objname - object name
--**********************************************************************/
declare @text_count int,
        @text       varchar(255),
        @line       varchar(255),
        @split      tinyint,
        @lf         char(1)
select  @lf = char(10)

if @@trancount = 0
begin
        set transaction isolation level 1
        set chained off
end

/***** 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 the current database."
        return (1)
end

/***** See if @objname exists. */
if (object_id(@objname) is NULL)
begin
        print "Object does not exist in this database."
        return (1)
end

select  text
into    #text
from    syscomments 
where   id = object_id(@objname)

select  @text_count = @@rowcount

/***** Parse and print the text one line at a time. */        
set rowcount 1
while @text_count > 0
begin
        select  @text_count = @text_count - 1,
                @text  = text + space( ( 255 - datalength( text ) ) 
                                       * sign( @text_count ) ),
                @split = charindex( @lf, text )
        from    #text

        delete  #text
        
        while   @split > 0
        begin
                select  @line  = @line + substring( @text, 1, @split - 1 
),
                        @text  = right( @text, datalength( @text ) - 
@split )
                print "%1!", @line
                select  @split = charindex( @lf, @text ),
                        @line  = NULL
        end

        if @text_count = 0
                print "%1!", @text
        else
                select  @line = @text        
end
set rowcount 0
go

if object_id('sp_helpcode') is not null
begin
    print '<<< Created procedure dbo.sp_helpcode >>>'
    grant execute on dbo.sp_helpcode to public
end
else
begin
    print '<<< Failed creating proc dbo.sp_helpcode >>>'
end
go