How to write stored procedure use SP_HELPTEXT for getting information of objects belong to another database
I would recommend against sp_helptext in general.

SELECT [schema] = s.name, [object] = o.name, m.definition 
  FROM otherdatabase.sys.sql_modules AS m
  INNER JOIN otherdatabase.sys.objects AS o
  ON m.[object_id] = o.[object_id]
  INNER JOIN otherdatabase.sys.schemas AS s
  ON o.[schema_id] = s.[schema_id];


If you need the database name to be dynamic, you can do:

DECLARE @db sysname = N'otherdatabase';

DECLARE @exec nvarchar(520) = @db + '.sys.sp_executesql';

DECLARE @sql nvarchar(max) = N'SELECT [schema] = s.name, 
    [object] = o.name, m.definition 
  FROM sys.sql_modules AS m
  INNER JOIN sys.objects AS o
  ON m.[object_id] = o.[object_id]
  INNER JOIN sys.schemas AS s
  ON o.[schema_id] = s.[schema_id];';

EXEC @exec @sql;