A SQL query statement you can use to delete all stored procedure in your database. This will permanently delete all the stored procedure scripts, so make you have the correct database and you back-up.
Use with caution.
SQL Query Statement:
USE DBNAME
GO
declare @procName sysname
declare someCursor cursor FOR
SELECT name FROM sysobjects WHERE type = 'P' AND objectproperty(id, 'IsMSShipped') = 0
open someCursor
fetch next FROM someCursor INTO @procName
while @@FETCH_STATUS = 0
begin
exec('drop proc ' + @procName)
fetch next FROM someCursor INTO @procName
end
close someCursor
deallocate someCursor
go
L.
SQL: Delete All Stored Procedure
Lerrie | Wednesday, March 18, 2015 | Labels: SQL Server, stored procedure
Below is a query statement you can use to delete all the tables of the database you selected/using. This will permanently delete all tables together with the schema and records of each table.
Double check and make sure you are deleting from the correct database.
Use with caution.
SQL Query Statement:
USE TESTDB
GO
DECLARE tables_cursor CURSOR
FOR SELECT name FROM sysobjects WHERE type = 'U'
OPEN tables_cursor
DECLARE @tablename sysname
FETCH NEXT FROM tables_cursor INTO @tablename
WHILE (@@FETCH_STATUS <> -1)
BEGIN
EXEC ('DROP TABLE ' + @tablename)
FETCH NEXT FROM tables_cursor INTO @tablename
END
DEALLOCATE tables_cursor
GO
L.
Double check and make sure you are deleting from the correct database.
Use with caution.
SQL Query Statement:
USE TESTDB
GO
DECLARE tables_cursor CURSOR
FOR SELECT name FROM sysobjects WHERE type = 'U'
OPEN tables_cursor
DECLARE @tablename sysname
FETCH NEXT FROM tables_cursor INTO @tablename
WHILE (@@FETCH_STATUS <> -1)
BEGIN
EXEC ('DROP TABLE ' + @tablename)
FETCH NEXT FROM tables_cursor INTO @tablename
END
DEALLOCATE tables_cursor
GO
L.
Subscribe to:
Posts (Atom)




