当前位置: 代码迷 >> Sql Server >> 在存储过程中把查询结果保存下来,后面接着用?该怎么解决
  详细解决方案

在存储过程中把查询结果保存下来,后面接着用?该怎么解决

热度:92   发布时间:2016-04-27 16:48:50.0
在存储过程中把查询结果保存下来,后面接着用?
在存储过程中,把查询结果保存下来,想用临时表,但是想在临时表中多加个字段作为主键,语句该如何写?
select   aaa,bbb,ccc   into   #tempTableA(id       int     IDENTITY(1,1)   not   null     primary   key,aaa,bbb,ccc)   from   tableA   where   ....
这样行不?
怎么写才对呢?
谢谢!


------解决方案--------------------
create table #tempTableA(id int IDENTITY(1,1) not null primary key,aaa int,bbb int)
insert into #tempTableA select aaa,bbb form table a where
  相关解决方案