您好,欢迎访问一九零五行业门户网

mssql 创建临时表代码

mssql 创建临时表代码
if object_id('tempdb.dbo.#table') is not null 
  drop table #table
go
create table #table([字段] 类型)//上面这段代码是判断临时表#table是否存在了,如果是就删除,否则就创建这个临时表。
/*
关于mssql server临时表相关操作
建临时表
       方法一:
create table #临时表名(字段1 约束条件,
                      字段2 约束条件,
                  .....)
        create table ##临时表名(字段1 约束条件,
                          字段2 约束条件,
                      .....)
        方法二:
select * into #临时表名 from 你的表;
       select * into ##临时表名 from 你的表;
注:以上的#代表局部临时表,##代表全局临时表
查询临时表
     select * from #临时表名;
       select * from ##临时表名;
删除临时表
     drop table #临时表名;
       drop table ##临时表名;
其它类似信息

推荐信息