>Recently, I have started a thread about removing all tables from a database. The approach of sp_MsForEachTable was proposed. However, occasionnaly, my server doesn't recognize this stored procedure. I need to have something bullet proof. Another thread I created today was about the ability to check the existence of one particular table and remove it from the database if found. This is also good. Now, I need some code to select all tables from the database and loop delete each of them. Is such a script possible?
USE YourDataBase
DECLARE @TableName AS varchar(8000)
DECLARE @sql AS varchar(8000)
SELECT @TableName = MIN(Table_Name) FROM INFORMATION_SCHEMA.Tables
WHILE @TableName IS NOT NULL
BEGIN
SET @sql = 'DROP TABLE '+@TableName
EXEC (@sql)
SELECT @TableName = MIN(Table_Name) FROM INFORMATION_SCHEMA.Tables WHERE Table_Name > @TableName
END
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.