Deleting stored procedures programmatically

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";
Identify1Asked:
Who is Participating?
 
Mirza AbazovicSoftware DeveloperCommented:
SqlCommand komanda = new SqlCommand("DROP PROCEDURE  ManagerTesterSP1", MyConnection);
komanda.CommandType = CommandType.StoredProcedure;
komanda.ExecuteNonQuery();

0
 
SwapnilSoftware ArchitectCommented:
Hi Identify1,

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

Regards,
NetSwap
0
 
Gautham JanardhanCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.