how to delete entire table or stored procedure at a time in sql ?


sometime we need to delete all the table at a time ,so i am writing a code to delete table and  Stored  procedure.

1-For table deletion


declare @procName varchar(500) declare cur cursor for select [name] from sys.objects where type = 'u' open cur fetch next from cur into @procName while @@fetch_status = 0 begin exec('drop table ' + @procName) fetch next from cur into @procName end close cur deallocate cur

2-For Stored procedure deletion-

declare @procName varchar(500) declare cur cursor for select [name] from sys.objects where type = 'p' open cur fetch next from cur into @procName while @@fetch_status = 0 begin exec('drop procedure ' + @procName) fetch next from cur into @procName end close cur deallocate cur

Comments

Popular posts from this blog

Dynamic Mega Menu With Asp.Net with c#,java script and Sql Server.

Bootstrap Modal Popup keep open on PostBack in ASP.Net

Export div content to PDF Using ITextSharp in asp.net