--游标的例子(删除包含'T'字母的表)
declare @sql varchar(200),@table varchar(200)
declare fetch_id cursor for Select name From sysobjects Where OBJECTPROPERTY(id,'IsUserTable')=1 and name like '%t%'
open fetch_id
fetch fetch_id into @table
while @@fetch_status=0
begin
set @sql='drop table '+@table
Exec master..xp_cmdshell @sql,No_Output
fetch next from fetch_id into @table
end
close fetch_id
deallocate fetch_id