Solved

Deleting stored procedures programmatically

Posted on 2006-07-07
6
291 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now