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.
Subscribe to:
Post Comments (Atom)





0 comments:
Post a Comment