我有名为db_Database数据库,现在在数据处理过程中创建了临时表#t_temp,现在想在这个临时表bytecount列上创建索引,我的做法是
create index idx_bytecount 
on #t_temp (bytecount)
但系统报错:无法在 '#t_temp' 上创建索引,因为此表在数据库 'db_Database' 中不存在。
请问这是为什么呢?临时表有特殊的建立索引的方法吗?请问我该怎么做?谢谢!

解决方案 »

  1.   

    create index idx_bytecount
    on #t_temp (bytecount) 要跟创建#t_temp的语句放在一起.
      

  2.   

    用##t_temp
    create index idx_bytecount 
    on ##t_temp (bytecount) 
      

  3.   

    create index idx_bytecount 
    on #t_temp (bytecount) 
    是和该当存储过程放在一起的吗?
    -------------------------
    create table #t_temp 
    (
    ...
    )create index idx_bytecount 
    on #t_temp (bytecount) 
      

  4.   

    我是用的select ... into #t_temp的方法创建的临时表,请问这样的话怎么在临时表上建立索引呢?