获取临时表的结构(如生成 sql 脚本)并清除当前实例的临时表 [英] Get structure of temp table (like generate sql script) and clear temp table for current instance
本文介绍了获取临时表的结构(如生成 sql 脚本)并清除当前实例的临时表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取临时表的结构然后删除临时表.是否有用于临时表的 sp_helptext?最后是否可以在同一会话或查询窗口中删除临时表?
示例:
How do I get structure of temp table then delete temp table. Is there a sp_helptext for temp tables? Finally is it possible to then delete temp table in same session or query window?
Example:
select *
into #myTempTable -- creates a new temp table
from tMyTable -- some table in your database
tempdb..sp_help #myTempTable
参考.
推荐答案
临时表名需要加引号,使用drop table ...
后可以直接删除临时表.
You need to use quotes around the temp table name and you can delete the temp table directly after using drop table ...
.
select *
into #myTempTable -- creates a new temp table
from tMyTable -- some table in your database
exec tempdb..sp_help '#myTempTable'
drop table #myTempTable
这篇关于获取临时表的结构(如生成 sql 脚本)并清除当前实例的临时表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文