Pages

Tuesday, July 12, 2011

SqlQuery to delete all procedures and tables

Views
To delete all tables with a single query

sp_MSforeachtable "DROP TABLE ? PRINT '? dropped' "


==============================================


To delete all procedures from sqlserver




CREATE Procedure [dbo].[DeleteAllProcedures]
As
      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
            if @procName <> 'DeleteAllProcedures'
                  exec('drop procedure ' + @procName)
                  fetch next from cur into @procName
      end
      close cur
      deallocate cur
--Go
      --Grant Execute On dbo.DeleteAllProcedures To Public
--Go

0 comments:

Post a Comment

 

Web Design Company karimnagar, Web Designing warangal, Logo Design Company nizamabad, Indian Website Design Company, maddysoft.co.in