最近作數據轉移,因爲誤操做,在系統表master表裏建立了N多表 實在是無法刪sql
找到如下方法共享一下數據庫
--指定要刪除的數據庫中的表 use master go declare @sql varchar(8000),@TableName varchar(100) begin declare cur cursor for select Name from sysobjects where xtype='p' --查詢系統對象,即全部的表名,存儲過程,函數等等 open cur fetch next from cur into @TableName while @@fetch_status=0 begin set @sql='drop table '+@TableName --DROP DEFAULT PROCEDURE 根據刪除對象類型對應調整,例如是存儲過程的話 即drop procedure exec (@sql) fetch next from cur into @TableName end close cur deallocate cur end --select * from sysobjects where xtype='p' order by crdate