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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:32:06+00:00 2026-05-14T18:32:06+00:00

Happy Monday o/ I’m looking to do the following within a stored proc select

  • 0

Happy Monday o/

I’m looking to do the following within a stored proc

  select @parameter="fooproc"
  drop procedure @parameter

instead of

  drop procedure fooproc

But it’s choking with a syntax error. Is there some way I can bend this to my will? I would’ve expected to be able to do this.

I’ve tried a few permutations of type declaration of @parameter to no avail.

Thoughts?

  • 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-14T18:32:06+00:00Added an answer on May 14, 2026 at 6:32 pm

    Only with dynamic SQL:

    DECLARE @sql AS VARCHAR(2000)
    
    SELECT @sql = STR_REPLACE('drop procedure {@parameter}', '{@parameter}', @parameter)
    
    EXEC ( @sql )
    

    I like to validate object names against database metadata before doing things like this. This protects against errors up front and even injection in the later dynamic section.

    i.e. something like:

    IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = @parameter)
    BEGIN
        DECLARE @sql AS VARCHAR(2000)
        SELECT @sql = STR_REPLACE('drop procedure {@parameter}', '{@parameter}', @parameter)
        EXEC ( @sql )
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're pretty happy with SVN right now, but Joel's tutorial intrigued me. So I
happy holidays! i have a tablelayoutpanel (10x10). within each cell i have a picturebox
I was happy to cobble some code together that gives me a nice looking
Happy Monday to you all! Here is my situation. Any assistance greatly appreciated! I
was happy when found css3/Mozillas multiple text column option, BUT source1 & source2 prove
I'd be happy to have very soft character >> instead of white-space, like this:
I'm very happy that Lion introduced NSRegularExpression , but I can't understand why the
I've installed cherokee and am very happy with it. But now I'm wondering how
I was a happy customer of Google Analytics starting from the Urchin times. But
I was happy for the standard library to get a to_string function, but now

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.