Solved

Deleting stored procedures programmatically

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Iterate two lists and remove inactive 11 49
How to iterate over object and get property name and value 4 26
Not showing page correctly 3 31
Error on Add method 1 38
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…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

867 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

16 Experts available now in Live!

Get 1:1 Help Now