Get structure of temp table (like generate sql script) and clear temp table for current instance

前端 未结 7 1983
粉色の甜心
粉色の甜心 2021-01-30 19:56

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

相关标签:
7条回答
  • 2021-01-30 20:36

    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
    
    0 讨论(0)
提交回复
热议问题