use DATABASENAME
--DATABASENAME 是待清理的数据库
GO
DECLARE @au_lname varchar(40),@SQLString NVARCHAR(500)
declare tb cursor for
select name from sysobjects where xtype='U'
OPEN tb
-- Perform the first fetch.
FETCH NEXT FROM tb INTO @au_lname
-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
-- This is executed as long as the previous fetch succeeds.
FETCH NEXT FROM tb INTO @au_lname
SET @SQLString='Drop table '+ @au_lname
EXEC sp_executesql @SQLString
--DROP TABLE @au_lname
END
CLOSE tb
DEALLOCATE tb
GO