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
。net工程师
原文地址:https://www.cnblogs.com/yuners/p/13751638.html