---
title: "游历数据库内所有名字符合条件的表"
author: "flon"
date: "2009-11-06T13:58:00Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2014-10-31T13:42:36Z"
id: 2150084
url: "https://flon.iteye.com/blog/2150084"
---

declare @cur varchar(50)  
declare curname cursor  
for  
select name from test.dbo.sysobjects where name like 'web\_supply\_%' or name like'sj\_%'  
open curname  
fetch next from curname into @cur  
while @@fetch\_status=0  
begin  
declare @strSql varchar(500)  
set @strSql='drop table '+ @cur  
exec( @strSql)  
fetch next from curname into @cur  
end  
close curname  
deallocate curname