Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6721709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:21:41+00:00 2026-05-26T09:21:41+00:00

I have 40 or so stored procedures that i would like to be able

  • 0

I have 40 or so stored procedures that i would like to be able to print out and refactor on paper then make the changes to the procedures. I have come across a couple of different possibilities but none so far that fit what I want but a little tweaking may fix that. the first

select 
  text 
from 
  syscomments 
where 
  id in (select id from sysobjects where xtype='p' and name LIKE 'qscore_Corp%')

but this returns all the code unformatted on single lines.

using sp_helptext is an option also but i have not figured out how to concatenate multiple into one long table of text.

My goal is to make it so that I can print the source of these 40 procedures from one text file with the formatting i have used in each procedure.

SOLVED::: By Martin thanks again.
I made a small tweak to his solution that pulled the procs i needed.
DECLARE @stored_procedure_code nvarchar(MAX)
SET @stored_procedure_code = ”

    SELECT @stored_procedure_code = @stored_procedure_code + '' + ISNULL(OBJECT_DEFINITION(object_id),'')
    FROM sys.procedures WHERE name LIKE 'qscore_Corp%'

    SELECT  @stored_procedure_code AS [processing-instruction(x)] FOR XML PATH('') 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:21:41+00:00Added an answer on May 26, 2026 at 9:21 am

    Something Like

    DECLARE @stored_procedure_code nvarchar(MAX) = ''
    
    SELECT @stored_procedure_code = @stored_procedure_code + '
    /*****************************************************************************/
    GO
    
    ' + ISNULL(OBJECT_DEFINITION(object_id),'')
    FROM sys.procedures 
    WHERE object_id IN (object_id('foo'),object_id('foo_bar'))
    
    SELECT  @stored_procedure_code AS [processing-instruction(x)] FOR XML PATH('') 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a stored procedure that will update values in a
I have several Stored Procedures that when added to my dbml, it seems that
I have some complex stored procedures that may return many thousands of rows, and
I have stored procedures in SQL Server T-SQL that are called from .NET within
I have a stored procedure that basically calls 7 or 8 other stored procedures.
I have a c# application that interfaces with the database only through stored procedures.
I have a rather huge query that is needed in several stored procedures, and
We have an existing application that relies heavily on stored procedures and untyped DataSets.
We currently have an application that depends largely on stored procedures. There is a
In a part of my data warehousing stored procedures, i have a procedure that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.