怎样删除库里所有表名以“tmp_”开头的表?
一句sql能搞定不?
谢谢
------解决方案--------------------declare cur cursor
read_only
for select distinct table_name from information_schema.columns where table_name like 'tmp_% '
declare @name varchar(40),@sql varchar(1000)
open cur
fetch next from cur into @name
while (@@fetch_status =0)
begin
set @sql = 'drop table ' + @name
exec (@sql)
fetch next from cur into @name
end
close cur
deallocate cur
go