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

Bootstrap Modal Popup keep open on PostBack in ASP.Net

Resolved Issue in Asp core 3.0 serializersettings does not exist in AddJsonOptions

.Net most asked interview questions for experienced professionals (C#,Asp WEBFORM,MVC,ASP CORE,WEB API,SQL Server,Java Script,Jquery)