-- 清除数据库所有表
declare @tablename nvarchar(50)
declare @sql nvarchar(250)
declare cur cursor for
select name from sys.tables
open cur fetch next from cur into @tablename
while(@@FETCH_STATUS = 0)
begin
set @sql = 'drop table ' + @tablename
exec sp_executesql @sql
fetch next from cur into @tablename
end
close cur
deallocate cur