hi to all of u
some time we in need to delete all stored procedures and tables from database
so for that we need a single query which do the all the work. below is the query once u run both query all tables and stored procedure of that database is drooped.
but carefully because once you dropped u cant get them back--
----------drop all tables from database-----------
exec sp_MSforeachtable "DROP TABLE ? PRINT '? to be dropped' "
------------drop all sp's in a database---------------
DECLARE @procedureName varchar(500)
DECLARE cur CURSOR
FOR SELECT [name] FROM sys.objects WHERE type = 'p'
OPEN cur
FETCH NEXT FROM cur INTO @procedureName
WHILE @@fetch_status = 0
BEGIN
EXEC('DROP PROCEDURE ' + @procedureName)
FETCH NEXT FROM cur INTO @procedureName
END
CLOSE cur
DEALLOCATE cur
this works i have tested it several time with MS sql server 2005
Showing posts with label Delete All Stored Procedures and Tables. Show all posts
Showing posts with label Delete All Stored Procedures and Tables. Show all posts
Subscribe to:
Posts (Atom)
ASP.NET Core
Certainly! Here are 10 advanced .NET Core interview questions covering various topics: 1. **ASP.NET Core Middleware Pipeline**: Explain the...
-
The error message you encountered ("DeleteService FAILED 1072: The specified service has been marked for deletion") indicates tha...
-
replace html of a div using jquery this is simple . just use .html() method of jquery to set new html for a div . $ ( "#divID...
-
declare @ProductIds nvarchar(50)='18,19' SELECT * FROM products Where (',' + @ProductIds +',' LIKE '%,' ...