Script SP using an SP

  • I know I can navigate through object explorer, right-clicking on a stored procedure and script it out. But, is there a quick way to pass a procedure name to another procedure to script it out?

    I see the procedure in the routine_definition field in INFORMATION_SCHEMA.ROUTINES, but it looks like it has been optimized as I don'e see any CRLFs. How can I format it so it is more humanly readible?

    Thanks...

  • how about sp_helptext 'sp_who2'

  • That is way too simple. It formats it much better than simply looking in the system table, but it still doesn't format it the same way as when I script it out. Strangely, it does format 'sp_who2' and some others correctly, but not all of them.

    Is there a setting in SSMS 2005 that would cause it to format differently?

  • PRINT OBJECT_DEFINITION(OBJECT_ID(N'master.dbo.sp_helptext', N'P'))

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply