How to list source code of store procedures?

To list source code one can call dbo.sp_helptext '<store procedure>' to list code.

exec dbo.sp_helptext 'sp_databases'

create procedure sys.sp_databases
set nocount on


Another way of viewing code is to query syscomments but it doesn’t format the output.
select, text
FROM syscomments sc, sysobjects so
where =
and name = 'sp_databases'
order by number, colid


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.