批量删除表
CREATE PROCEDURE dropTable @tableName varchar(40)
AS
declare cur cursor read_only
for select distinct table_name from information_schema.columns where table_name like @tableName
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
AS
declare cur cursor read_only
for select distinct table_name from information_schema.columns where table_name like @tableName
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