Heim >Datenbank >MySQL-Tutorial >mssql 创建临时表代码

mssql 创建临时表代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:47:271172Durchsuche

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 ##临时表名;

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn