日期:2014-05-18  浏览次数:20342 次

在存储过程中把查询结果保存下来,后面接着用?
在存储过程中,把查询结果保存下来,想用临时表,但是想在临时表中多加个字段作为主键,语句该如何写?
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