For Trigger:
SELECT OBJECT_NAME(a.[ID]) TriggerName, b.[Text] TriggerCode FROM SysObjects a INNER JOIN SysComments b ON a.[ID] = b.[ID]
WHERE a.Type = 'TR'
For Procedure:
replace the Type with 'P'
You can also find the Procedure and Function details from the information_schema.routines view