赞
踩
SELECT row_number()over(order by Name) as FID,Name into #temp FROM SysObjects Where XType='U' --类型,U为实体表 and name like 'TMP%' --表名过滤(自定义就好) ORDER BY Name declare @count int = 0 --行数 declare @i int = 1 --循环所用到的索引 declare @tableName varchar(50) = 0 --表名称 select @count=count(1) from #temp --写入行数值 --开始循环 while(@i <= @count) begin select @tableName=Name from #temp where FID=@i exec('drop table '+@tableName+'') --删除表 select @i=@i+1 --索引+1 end drop table #temp
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。