2个问题: 
第一个:建立一个临时表
王里面插入10条数据然后在插入之后删除临时表  第二个:临时表一般是用完之后就删除么?高手能帮写个这个程序么谢谢~!!

解决方案 »

  1.   

    创建
    CREATE TABLE #temp删除drop table #temp
      

  2.   

    第二个:临时表一般是用完之后就删除么?
    ------------------------
    是的,一般用完就drop
      

  3.   

    -- 创建临时表
    create table #temp
    (
        id int not null
    )
    --插入数据
    insert into #temp values(1)
    insert into #temp values(2)
    insert into #temp values(3)
    insert into #temp values(4)
    insert into #temp values(5)
    insert into #temp values(6)
    -- 查询数据
    select * from #temp
    -- 删除临时表
    drop table #temp
      

  4.   

    #temp  啥意思啊 是  #临时表名么  一般都什么做表名是不是以"时分秒"为表名?
      

  5.   

    对,#表示就是临时表,temp就表名,表名随便你取什么啊,这个没关系。一般只要取的有意义点就好了!!!
      

  6.   

    本地临时表仅在当前会话中可见,而全局临时表在所有会话中都可见。临时表不能分区。本地临时表的名称前面有一个数字符号 (#table_name),而全局临时表的名称前面有两个数字符号 (##table_name)。
      

  7.   

    临时表与永久表相似,但临时表存储在 tempdb 中,当不再使用时会自动删除。 临时表有两种类型:本地和全局。它们在名称、可见性以及可用性上有区别。本地临时表的名称以单个数字符号 (#) 打头;它们仅对当前的用户连接是可见的;当用户从 SQL Server 实例断开连接时被删除。全局临时表的名称以两个数字符号 (##) 打头,创建后对任何用户都是可见的,当所有引用该表的用户从 SQL Server 断开连接时被删除。
      

  8.   


    SQL Server ?1.
    操作 临时表 ,与操作普通表几乎一样2.
    局部临时表一个会话(连接)结束之后,会自动清除, 不需要显示 DROP
      

  9.   

    create table #temp
    (
        id int not null
    )insert into #temp values(1);
    -- 查询数据
    select * from #temp
    -- 删除临时表
    drop table #temp
      

  10.   

    #temp
    带#就是临时表,#order,#123都可以
    创建临时表
    create table #temp
    (
        id int not null
    )
    插入数据:insert into #temp values(1)
    查询数据:select * from #temp
    删除临时表:drop table #temp
    去网上一搜一大堆的