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 8404273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:33:27+00:00 2026-06-09T22:33:27+00:00

I want to dynamically create a Drop/Create Script. For that I can calculate the

  • 0

I want to dynamically create a Drop/Create Script. For that I can calculate the Create part as below.

SELECT definition FROM sys.sql_modules

My Query – can you suggest something for the Drop Stored Proc Part…

I am trying a Create/Drop Script for Stored Proc

  • 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-06-09T22:33:29+00:00Added an answer on June 9, 2026 at 10:33 pm
    DECLARE @proc NVARCHAR(511); -- presumably a parameter
    SET @proc = N'dbo.sp_help_job';
    
    
    DECLARE @sql NVARCHAR(MAX);
    
    SELECT @sql = N'DROP PROCEDURE ' + @proc + ';
    GO
    ' + definition
    FROM sys.sql_modules
    WHERE [object_id] = OBJECT_ID(@proc);
    
    PRINT @sql;
    -- EXEC sp_executesql @sql;
    

    Comparisons of join vs. OBJECTPROPERTY method for Pankaj:

    enter image description here

    Click to enlarge:

    enter image description here

    Don’t copy and try to use the OUTPUT from the second screen shot. Why on earth would you do this? This is SQL Server’s internal representation of a parameterized version of the query. Let me paste the code so that you aren’t doing unexplainable things with what I’m trying to show you:

    SELECT OBJECT_NAME(m.[object_id]), m.[object_id]
    FROM sys.all_sql_modules AS m
    INNER JOIN sys.all_objects AS o
    ON m.[object_id] = o.[object_id]
    WHERE o.type = N'P';
    
    SELECT OBJECT_NAME([object_id]), [object_id]
    FROM sys.all_sql_modules 
    WHERE OBJECTPROPERTY([object_id], 'IsProcedure') = 1;
    

    Run those and check the results in profiler. Am I still “wrong” Pankaj? Would you like to waste any more of everyone’s time today?

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

Sidebar

Related Questions

I want to dynamically create some image from Java and save it to a
I want to dynamically create variable from string in objective C. Like NSClassFromString thats
How can I create a day drop-down that shows the correct number of days
I want to dynamically create variable names in java el. The problem is that
I want to dynamically create a <select></select> (or maybe a textbox with autocomplete) input
i want to create select option dynamically. i have two array year and month.
I just want to add ContextMenu for several objects that I create dynamically, but
I want to dynamically create instance method of child class through class method of
I want to dynamically create object of HtmlDivElement in my jsf managed bean and
I want to dynamically create controls in my bean. I am using JSF 2.0

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.