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

  • Home
  • SEARCH
  • 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 131341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:05:24+00:00 2026-05-11T06:05:24+00:00

Any pointers on how I can programmatically get exactly the identical stored procedure source

  • 0

Any pointers on how I can programmatically get exactly the identical stored procedure source from SQL Server 2005, as when I right-click on that stored procedure in SQL Server Management Studio and select modify?

I’m trying using SMO, but there are some textual differences. The procedure always has CREATE, not ALTER, and there are some differences in the header, such as missing GOs in the version I’m getting programmatically. I can fix these up, but perhaps there is a better way?

Again, I’m in SQL Server 2005, using SMSE. Using SMO via Visual Studio 8 2008.

Update: Gotten some answers that tell the basics of how to retrieve the stored procedure. What I’m looking for is retrieving the text identical (or nearly identical) to what the GUI generates.

Example: for sp_mysp, right-click in Management Studio, select modify. This generates:

    USE [MY_DB]       GO       /****** Object:  StoredProcedure [dbo].[sp_mysp]    Script Date: 01/21/2009 17:43:18 ******/       SET ANSI_NULLS ON       GO       SET QUOTED_IDENTIFIER ON       GO       -- =============================================     -- Author:           -- Create date:      -- Description:      -- =============================================     ALTER PROCEDURE [dbo].[sp_mysp] 

I’d like to programmatically get the same thing (notice the GOs in the header, and the fact that it’s an ALTER PROCEDURE. Ideally, I’d like to get this with minimal programmatic fixing up of the source retrieved.

I’d be happy to only get something that differed in the Script Date details . . .

  • 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. 2026-05-11T06:05:25+00:00Added an answer on May 11, 2026 at 6:05 am
    EXEC sp_helptext 'your procedure name'; 

    This avoids the problem with INFORMATION_SCHEMA approach wherein the stored procedure gets cut off if it is too long.

    Update: David writes that this isn’t identical to his sproc…perhaps because it returns the lines as ‘records’ to preserve formatting? If you want to see the results in a more ‘natural’ format, you can use Ctrl-T first (output as text) and it should print it out exactly as you’ve entered it. If you are doing this in code, it is trivial to do a foreach to put together your results in exactly the same way.

    Update 2: This will provide the source with a ‘CREATE PROCEDURE’ rather than an ‘ALTER PROCEDURE’ but I know of no way to make it use ‘ALTER’ instead. Kind of a trivial thing, though, isn’t it?

    Update 3: See the comments for some more insight on how to maintain your SQL DDL (database structure) in a source control system. That is really the key to this question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 167k
  • Answers 168k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Either manually add the All entry to the bound dataset… May 12, 2026 at 1:37 pm
  • Editorial Team
    Editorial Team added an answer Impersonation allows machine to machine impersonation, so the client browser… May 12, 2026 at 1:37 pm
  • Editorial Team
    Editorial Team added an answer refreshKrb5Config=true should be set for the KRB5LoginModule in jaas.conf. May 12, 2026 at 1:37 pm

Related Questions

Possible Duplicates: How can I get the size of an array from a pointer
I have a datagrid which I am using LINQ to fill, I then add
I have two models, A and B, and one light, L. I would like
I need to secure a WCF service that uses netTcpBinding and connects directly with

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.