IF EXISTS (Select Name from sys.objects WHERe object_id=1995154153)
DROp TABLE 后面怎么写?我希望用一行语句删除查询出来的这张表(但使用下面的语句出错):
DROP TABLE (Select Name from sys.objects WHERe object_id=1995154153)
--在线等,希望高手显身
请教SQL SERVER中DROP TABLE语句后面为Select查询结果时的写法
答案:2 悬赏:40 手机版
解决时间 2021-03-21 16:43
- 提问者网友:wodetian
- 2021-03-20 20:01
最佳答案
- 五星知识达人网友:走死在岁月里
- 2021-03-20 20:13
select identity(int,0,1) id, name into #t from sys.objects WHERe object_id='1995154153'
declare @s int,@id int,@name varchar(10)
set @s=1
select @id =sum(id) from #t
while @S<@id
begin
select @name=name from #t where id=@s;
print @name
exec('drop table '+@name)
set @s=@s+1
end
declare @s int,@id int,@name varchar(10)
set @s=1
select @id =sum(id) from #t
while @S<@id
begin
select @name=name from #t where id=@s;
print @name
exec('drop table '+@name)
set @s=@s+1
end
全部回答
- 1楼网友:举杯邀酒敬孤独
- 2021-03-20 20:47
额
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯