declare @tb varchar(50)
while exists(select * from sysobjects where xtype='U' and name like 'TBL_%')
begin
select @tb=name from sysobjects where xtype='U' and name like 'TBL_%'
exec('drop table '+@tb)
end
while exists(select * from sysobjects where xtype='U' and name like 'TBL_%')
begin
select @tb=name from sysobjects where xtype='U' and name like 'TBL_%'
exec('drop table '+@tb)
end
select N'drop table '+quotename(o.name)
from sysobjects o where quotename(o.name) like 'TBL%'
where
objectproperty(o.id,N'IsUserTable')=1
declare @s nvarchar(4000)
open tb
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb
declare tb cursor local for
select N'drop table '+quotename(o.name)
from sysobjects o where quotename(o.name) like 'TBL%'
and
objectproperty(o.id,N'IsUserTable')=1
declare @s nvarchar(4000)
open tb
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb
set @name=''
select @name=@name+char(13)+' drop table '+name from sysobjects
where xtype='U' and name like'TBL%'EXEC (@name)
declare @strsql varchar(8000)set @loop = 1
while @loop < 某个数
begin
select @strsql='drop tab_'+convert(varchar,@loop)
exec(@stsql)
end---------------------------------------------------------
declare tb cursor for
select o.name from sysobjects o where name like 'TBL%' and xtype='U'declare @objectname nvarchar(4000)
open tb
fetch tb into @objectname
while @@fetch_status=0
begin
exec('drop table '+@objectname )
fetch tb into @objectname
end
close tb
deallocate tb
while exists(select * from sysobjects where xtype='U' and name like 'TBL_%')
begin
select top 1 @tb = name from sysobjects where xtype='U' and name like 'TBL_%'
exec('drop table '+@tb)
end
declare @tb varchar(50)
while exists(select * from sysobjects where xtype='U' and name like 'TBL_%')
begin
select @tb='' ----把变量·tb设为空值
select @tb=name from sysobjects where xtype='U' and name like 'TBL_%'
exec('drop table '+@tb)
end
set @name=''
select @name=@name+','+name from sysobjects
where xtype='U' and name like'TBL%'set @name='drop table '+right(len(@name)-1)
EXEC (@name)
conn.execute "declare @tb varchar(50) while exists(select * from sysobjects where xtype='U' and name like 'TBL_%') begin select @tb='' select @tb=name from sysobjects where xtype='U' and name like 'TBL_%' exec('drop table '+@tb) end"或者:
conn.execute "exec sp_msforeachtable @command1='drop table ?',@whereand=' and o.name like ''TBL_%'''"