Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Deleting stored procedures programmatically

Posted on 2006-07-07
6
296 Views
Last Modified: 2010-04-16
Is there any way to delete a stored procedure programatically?

Here is the way I create it:
"CREATE PROCEDURE dbo.ManagerTesterSP1 (@choice int, @sleep DateTime) AS      
if @choice = 1 begin return end else if @choice = 3 begin waitfor delay @sleep return end else if @choice = 2 begin declare @temp int declare @temp1 int set @temp = 0 set @temp1 = 1/@temp return end";
0
Comment
Question by:Identify1
6 Comments
 
LVL 16

Expert Comment

by:Swapnil Piparia
ID: 17056687
Hi Identify1,

execute sql "DROP PROCEDURE { procedure }" from command object with command.ExecuteNonQuery(sql)

Regards,
NetSwap
0
 
LVL 1

Accepted Solution

by:
mirzaAbazovic earned 500 total points
ID: 17056694
SqlCommand komanda = new SqlCommand("DROP PROCEDURE  ManagerTesterSP1", MyConnection);
komanda.CommandType = CommandType.StoredProcedure;
komanda.ExecuteNonQuery();

0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 17064025
u could use the DROP PROCEDURE [proc name]

command and execute it using the sqlcommand.executenonquery()
command text of sqlcommand will be my above said query
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Device Location 4 35
Keyboard 2 41
Jquery/JSON passing value from one function to another 12 60
VS 2013 installer,  Install, Update and uninstall via SCCM 6 25
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question