SQLSERVER 临时表创建

  • 判断临时表是否存在,存在则删除
    if OBJECT_ID('tempdb..#tempTable') IS NOT NULL
    
    begin
    
    DROP TABLE #temp_Table
    
    end

     

  • 创建临时表(' # '局部的临时表仅在会话里边, ' ## '全局的的临时表)
    create table #temp_Table(
        字段1 约束条件,
        字段2 约束条件,
        ...)
    create table #tempTable(
        字段1 约束条件,
        字段2 约束条件,
        ...)

     

  • 删除临时表
    DROP table #temp_Table

     

  • 清空临时表数据和约束
    truncate table #temp_Table

     

 

posted @ 2020-09-29 20:15  龙er飞  阅读(3947)  评论(0编辑  收藏  举报