Home > Database > Mysql Tutorial > mssql 创建临时表代码

mssql 创建临时表代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:47:27
Original
1189 people have browsed it

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

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template