DECLARE @Table NVARCHAR(300) DECLARE @Count Int = 0 DECLARE tmpCur CURSOR FOR SELECT name FROM sys.objects WHERE TYPE='U' AND name LIKE N'temp_cost%' order by name OPEN tmpCur FETCH NEXT FROM tmpCur INTO @Table WHILE @@FETCH_STATUS= 0 BEGIN DECLARE @sql VARCHAR(100) SELECT @sql='drop table ['+@Table+']' EXEC(@sql) Print convert(varchar(100),@Count)+':'+@sql SET @Count=@COUNT + 1 FETCH NEXT FROM tmpCur INTO @Table END CLOSE tmpCur DEALLOCATE tmpCur
以上是批量删除数据库中的表格!